<!DOCTYPE html>





    

    

    

    

<html lang="en-us">
<!-- Mirrored from docs.memfiredb.com/docs/db/guides/sql-grammar/ by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 27 Jun 2025 07:56:47 GMT -->
<head>
    <meta charset="utf-8" />
    <title>SQL语法 | MemFire Cloud在线文档</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="keywords" content="Documentation, Hugo, Hugo Theme, Bootstrap" />
    <meta name="author" content="Colin Wilson - Lotus Labs" />
    <meta name="email" content="support@aigis.uk" />
    <meta name="website" content="https://lotusdocs.dev/" />
    <meta name="Version" content="v0.1.0" />
    
    <link rel="icon" href="https://docs.memfiredb.com/favicon.ico" sizes="any">
<link rel="icon" type="image/svg+xml" href="https://docs.memfiredb.com/favicon.svg">
<link rel="apple-touch-icon" sizes="180x180" href="../../../../apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="../../../../favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../../../../favicon-16x16.png">
<link rel="manifest" crossorigin="use-credentials" href="https://docs.memfiredb.com/site.webmanifest">
<meta property="og:title" content="SQL语法" />
<meta property="og:description" content="MemFireDB 结构化查询语言（MSQL）是符合ANSI标准的结构化查询语言。兼容PostgreSQL 11.2版本。MemFireDB复用了PostgresSQL的原生查询层。MemFire支持所有的传统关系模型功能，例如引用完整性（例如外键）、JOIN、分布式事务、部分索引、触发器和存储过程。
MSQL的主要组件包括数据定义语言（DDL）、数据操作语言（DML）和数据控制语言（DCL）。这些组件由多个元素构成，包括数据类型、数据库对象、名称和限定符、表达式和注释。此外MSQL还提供了其他用途的组件，例如系统控制、事务控制和性能调试。
声明 描述 ABORT 回滚事务 ALTER DATABASE 更改数据库定义 ALTER DEFAULT PRIVILEGES 定义默认访问权限 ALTER DOMAIN 变更网域 ALTER GROUP 变更群组 ALTER POLICY 更改行级安全策略 ALTER ROLE 改变角色 ALTER SEQUENCE 更改序列定义 ALTER TABLE 变更表定义 ALTER USER 更改用户（角色） BEGIN 开始交易 COMMENT 在数据库对象上添加注释 COMMIT 提交交易 COPY 在表和文件之间复制数据 CREATE AGGREGATE 创建一个新的聚合 CREATE CAST 建立新的类型转换 CREATE DATABASE 创建一个新的数据库 CREATE DOMAIN 创建一个新域 CREATE EXTENSION 加载扩展 CREATE FUNCTION 创建一个新功能 CREATE INDEX 创建一个新索引 CREATE GROUP 创建一个新组（角色） CREATE OPERATOR 创建一个新的运算符 CREATE OPERATOR CLASS 创建一个新的运算符类 CREATE POLICY 创建一个新的行级安全策略 CREATE PROCEDURE 创建一个新程序 CREATE ROLE 创建一个新角色（用户或组） CREATE RULE 创建一个新规则 CREATE USER 创建一个新用户（角色） CREATE SCHEMA 创建一个新的架构（命名空间） CREATE SEQUENCE 创建一个新的序列生成器 CREATE TABLE 创建一个新表 CREATE TABLE AS 创建一个新表 CREATE TRIGGER 创建一个新触发器 CREATE TYPE 建立新类型 CREATE VIEW 创建一个新的视图 DEALLOCATE 取消分配准备好的语句 DELETE 从表中删除行 DO 执行一个匿名代码块 DROP AGGREGATE 删除汇总 DROP CAST 删除类型转换 DROP DATABASE 从系统中删除数据库 DROP DOMAIN 删除网域 DROP EXTENSION 删除扩展 DROP FUNCTION 删除功能 DROP GROUP 删除组（角色） DROP OPERATOR 删除运算符 DROP OPERATOR CLASS 删除操作员类别 DROP OWNED 删除角色拥有的对象 DROP POLICY 删除行级安全策略 DROP PROCEDURE 删除程序 DROP ROLE 删除角色（用户或组） DROP RULE 删除规则 DROP SEQUENCE 删除序列发生器 DROP TABLE 从数据库中删除表 DROP TRIGGER 删除触发器 DROP TYPE 删除用户定义的类型 DROP USER 删除用户（角色） END 提交事务 EXECUTE 执行准备好的语句 EXPLAIN 显示语句的执行计划 INSERT 在表格中插入行 LOCK 锁定 PREPARE 准备一份声明 REASSIGN OWNED 重新分配拥有的对象 RESET 将参数重置为出厂设置 REVOKE 删除访问权限 ROLLBACK 回滚事务 SELECT 从表中选择行 SET 设置系统，会话或事务参数 SET CONSTRAINTS 设置当前交易的约束 SET ROLE 设定角色 SET SESSION AUTHORIZATION 设置会话授权 SET TRANSACTION 设置事务行为 SHOW 显示系统，会话或事务参数的值 SHOW TRANSACTION 显示交易的属性 TRUNCATE 清除表格中的所有行 UPDATE 更新表中的行 数据定义语言（DDL） linkDDL语句通过CREATE、ALTER和DROP命令来定义数据库中的结构、更改定义以及删除定义。 声明 描述 ALTER DATABASE 更改数据库定义 ALTER SEQUENCE 更改序列发生器的定义 ALTER TABLE 更改表定义 CREATE AGGREGATE 创建一个新的聚集函数 CREATE CAST 创建新的类型转换 CREATE DATABASE 创建一个新的数据库 CREATE EXTENSION 加载扩展 CREATE FUNCTION 创建一个新功能 CREATE INDEX 创建一个新索引 CREATE OPERATOR 创建一个新的运算符 CREATE OPERATOR CLASS 创建一个新的运算符类 CREATE PROCEDURE 创建一个新程序 CREATE RULE 创建一条新规则 CREATE SCHEMA 创建一个新的架构（命名空间） CREATE SEQUENCE 创建一个新的序列生成器 CREATE TABLE 创建一个新表 CREATE TABLE AS 创建一个新表 CREATE TRIGGER 创建一个新触发器 CREATE TYPE 创建一种新的类型 CREATE VIEW 创建一个新的视图 DROP AGGREGATE 删除汇总 DROP CAST 删除类型转换 DROP DATABASE 从系统中删除数据库 DROP EXTENSION 删除扩展 DROP FUNCTION 删除功能 DROP OPERATOR 删除运算符 DROP OPERATOR CLASS 删除运算符类 DROP PROCEDURE 删除一个过程 DROP RULE 删除程序 DROP SEQUENCE 删除序列发​​生器 DROP TABLE 从数据库中删除表 DROP TYPE 删除用户定义的类型 DROP TRIGGER 删除触发器 TRUNCATE 清空一个表或者一组表 数据操作语言（DML） linkDML语句修改数据库的内容。 声明 描述 DELETE 从表中删除行 INSERT 向表插入行 SELECT 从表中选择行 UPDATE 更新表中的行 数据控制语言（DCL） linkDCL语句可以保护并防止数据库损坏。 声明 描述 ALTER DEFAULT PRIVILEGES 定义默认访问权限 ALTER GROUP 变更群组 ALTER POLICY 更改行级安全策略 ALTER ROLE 更改角色（用户或组） ALTER USER 更改用户 CREATE GROUP 创建一个新组（角色） CREATE POLICY 创建一个新的行级安全策略 CREATE ROLE 创建一个新角色（用户或组） CREATE USER 创建一个新用户（角色） DROP GROUP 移除群组 DROP POLICY 删除行级安全策略 DROP ROLE 删除角色（用户或组） DROP OWNED 删除拥有的对象 DROP USER 删除用户 GRANT 授予权限 REASSIGN OWNED 重新分配拥有对象 REVOKE 撤销权限 SET ROLE 设定角色 SET SESSION AUTHORIZATION 设置会话授权 事务控制语言（TCL） linkTCL语句管理数据库上的事务。 声明 描述 ABORT 回滚事务 BEGIN 开始事务 COMMIT 提交事务 END 提交事务 ROLLBACK 回滚事务 SET CONSTRAINTS 设置当前事务的约束 SET TRANSACTION 设置事务行为 SHOW TRANSACTION 显示事务的属性 会话和系统控制 link 声明 描述 RESET 将参数重置为出厂设置 SET 设置系统，会话或事务参数 SHOW 显示系统，会话或事务参数的值 性能控制 link 声明 描述 DEALLOCATE 取消分配准备好的语句 EXECUTE 执行准备好的语句 EXPLAIN 解释陈述的执行计划 PREPARE 准备一份声明 其他声明 link 声明 描述 COPY 在表和文件之间复制数据 DO 执行一个匿名代码块 ABORT link概要" />
<meta property="og:type" content="article" />
<meta property="og:url" content="index.html" /><meta property="og:image" content="../../../../opengraph/card-base-2_hu06b1a92291a380a0d2e0ec03dab66b2f_17642_filter_16093181652627614540.png"/><meta property="article:section" content="docs" />
<meta property="article:published_time" content="2023-12-13T17:39:49+08:00" />
<meta property="article:modified_time" content="2023-12-13T17:39:49+08:00" /><meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="../../../../opengraph/card-base-2_hu06b1a92291a380a0d2e0ec03dab66b2f_17642_filter_16093181652627614540.png"/>
<meta name="twitter:title" content="SQL语法"/>
<meta name="twitter:description" content="MemFireDB 结构化查询语言（MSQL）是符合ANSI标准的结构化查询语言。兼容PostgreSQL 11.2版本。MemFireDB复用了PostgresSQL的原生查询层。MemFire支持所有的传统关系模型功能，例如引用完整性（例如外键）、JOIN、分布式事务、部分索引、触发器和存储过程。
MSQL的主要组件包括数据定义语言（DDL）、数据操作语言（DML）和数据控制语言（DCL）。这些组件由多个元素构成，包括数据类型、数据库对象、名称和限定符、表达式和注释。此外MSQL还提供了其他用途的组件，例如系统控制、事务控制和性能调试。
声明 描述 ABORT 回滚事务 ALTER DATABASE 更改数据库定义 ALTER DEFAULT PRIVILEGES 定义默认访问权限 ALTER DOMAIN 变更网域 ALTER GROUP 变更群组 ALTER POLICY 更改行级安全策略 ALTER ROLE 改变角色 ALTER SEQUENCE 更改序列定义 ALTER TABLE 变更表定义 ALTER USER 更改用户（角色） BEGIN 开始交易 COMMENT 在数据库对象上添加注释 COMMIT 提交交易 COPY 在表和文件之间复制数据 CREATE AGGREGATE 创建一个新的聚合 CREATE CAST 建立新的类型转换 CREATE DATABASE 创建一个新的数据库 CREATE DOMAIN 创建一个新域 CREATE EXTENSION 加载扩展 CREATE FUNCTION 创建一个新功能 CREATE INDEX 创建一个新索引 CREATE GROUP 创建一个新组（角色） CREATE OPERATOR 创建一个新的运算符 CREATE OPERATOR CLASS 创建一个新的运算符类 CREATE POLICY 创建一个新的行级安全策略 CREATE PROCEDURE 创建一个新程序 CREATE ROLE 创建一个新角色（用户或组） CREATE RULE 创建一个新规则 CREATE USER 创建一个新用户（角色） CREATE SCHEMA 创建一个新的架构（命名空间） CREATE SEQUENCE 创建一个新的序列生成器 CREATE TABLE 创建一个新表 CREATE TABLE AS 创建一个新表 CREATE TRIGGER 创建一个新触发器 CREATE TYPE 建立新类型 CREATE VIEW 创建一个新的视图 DEALLOCATE 取消分配准备好的语句 DELETE 从表中删除行 DO 执行一个匿名代码块 DROP AGGREGATE 删除汇总 DROP CAST 删除类型转换 DROP DATABASE 从系统中删除数据库 DROP DOMAIN 删除网域 DROP EXTENSION 删除扩展 DROP FUNCTION 删除功能 DROP GROUP 删除组（角色） DROP OPERATOR 删除运算符 DROP OPERATOR CLASS 删除操作员类别 DROP OWNED 删除角色拥有的对象 DROP POLICY 删除行级安全策略 DROP PROCEDURE 删除程序 DROP ROLE 删除角色（用户或组） DROP RULE 删除规则 DROP SEQUENCE 删除序列发生器 DROP TABLE 从数据库中删除表 DROP TRIGGER 删除触发器 DROP TYPE 删除用户定义的类型 DROP USER 删除用户（角色） END 提交事务 EXECUTE 执行准备好的语句 EXPLAIN 显示语句的执行计划 INSERT 在表格中插入行 LOCK 锁定 PREPARE 准备一份声明 REASSIGN OWNED 重新分配拥有的对象 RESET 将参数重置为出厂设置 REVOKE 删除访问权限 ROLLBACK 回滚事务 SELECT 从表中选择行 SET 设置系统，会话或事务参数 SET CONSTRAINTS 设置当前交易的约束 SET ROLE 设定角色 SET SESSION AUTHORIZATION 设置会话授权 SET TRANSACTION 设置事务行为 SHOW 显示系统，会话或事务参数的值 SHOW TRANSACTION 显示交易的属性 TRUNCATE 清除表格中的所有行 UPDATE 更新表中的行 数据定义语言（DDL） linkDDL语句通过CREATE、ALTER和DROP命令来定义数据库中的结构、更改定义以及删除定义。 声明 描述 ALTER DATABASE 更改数据库定义 ALTER SEQUENCE 更改序列发生器的定义 ALTER TABLE 更改表定义 CREATE AGGREGATE 创建一个新的聚集函数 CREATE CAST 创建新的类型转换 CREATE DATABASE 创建一个新的数据库 CREATE EXTENSION 加载扩展 CREATE FUNCTION 创建一个新功能 CREATE INDEX 创建一个新索引 CREATE OPERATOR 创建一个新的运算符 CREATE OPERATOR CLASS 创建一个新的运算符类 CREATE PROCEDURE 创建一个新程序 CREATE RULE 创建一条新规则 CREATE SCHEMA 创建一个新的架构（命名空间） CREATE SEQUENCE 创建一个新的序列生成器 CREATE TABLE 创建一个新表 CREATE TABLE AS 创建一个新表 CREATE TRIGGER 创建一个新触发器 CREATE TYPE 创建一种新的类型 CREATE VIEW 创建一个新的视图 DROP AGGREGATE 删除汇总 DROP CAST 删除类型转换 DROP DATABASE 从系统中删除数据库 DROP EXTENSION 删除扩展 DROP FUNCTION 删除功能 DROP OPERATOR 删除运算符 DROP OPERATOR CLASS 删除运算符类 DROP PROCEDURE 删除一个过程 DROP RULE 删除程序 DROP SEQUENCE 删除序列发​​生器 DROP TABLE 从数据库中删除表 DROP TYPE 删除用户定义的类型 DROP TRIGGER 删除触发器 TRUNCATE 清空一个表或者一组表 数据操作语言（DML） linkDML语句修改数据库的内容。 声明 描述 DELETE 从表中删除行 INSERT 向表插入行 SELECT 从表中选择行 UPDATE 更新表中的行 数据控制语言（DCL） linkDCL语句可以保护并防止数据库损坏。 声明 描述 ALTER DEFAULT PRIVILEGES 定义默认访问权限 ALTER GROUP 变更群组 ALTER POLICY 更改行级安全策略 ALTER ROLE 更改角色（用户或组） ALTER USER 更改用户 CREATE GROUP 创建一个新组（角色） CREATE POLICY 创建一个新的行级安全策略 CREATE ROLE 创建一个新角色（用户或组） CREATE USER 创建一个新用户（角色） DROP GROUP 移除群组 DROP POLICY 删除行级安全策略 DROP ROLE 删除角色（用户或组） DROP OWNED 删除拥有的对象 DROP USER 删除用户 GRANT 授予权限 REASSIGN OWNED 重新分配拥有对象 REVOKE 撤销权限 SET ROLE 设定角色 SET SESSION AUTHORIZATION 设置会话授权 事务控制语言（TCL） linkTCL语句管理数据库上的事务。 声明 描述 ABORT 回滚事务 BEGIN 开始事务 COMMIT 提交事务 END 提交事务 ROLLBACK 回滚事务 SET CONSTRAINTS 设置当前事务的约束 SET TRANSACTION 设置事务行为 SHOW TRANSACTION 显示事务的属性 会话和系统控制 link 声明 描述 RESET 将参数重置为出厂设置 SET 设置系统，会话或事务参数 SHOW 显示系统，会话或事务参数的值 性能控制 link 声明 描述 DEALLOCATE 取消分配准备好的语句 EXECUTE 执行准备好的语句 EXPLAIN 解释陈述的执行计划 PREPARE 准备一份声明 其他声明 link 声明 描述 COPY 在表和文件之间复制数据 DO 执行一个匿名代码块 ABORT link概要"/>

    
    <script>(()=>{var t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,e=localStorage.getItem("theme");t&&e===null&&(localStorage.setItem("theme","dark"),document.documentElement.setAttribute("data-dark-mode","")),t&&e==="dark"&&document.documentElement.setAttribute("data-dark-mode",""),e==="dark"&&document.documentElement.setAttribute("data-dark-mode","")})()</script>
    
    
    
    
    
        
        
        
        
    
        
        
        
        
    
    
    <link rel="preconnect" href="https://fonts.gstatic.com/" />
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />
    <link href="https://fonts.googleapis.com/css?family=Inter:300,400,600,700|Fira+Code:500,700&amp;display=block" rel="stylesheet">

    <link rel="stylesheet" href="../../../scss/style.min.3c376716d7676031e43f6cdc5f3b857642dfe5127f5fd4540ab03d9d4fe8ebac97eff815fbd2f0910dd1307fddf53a15.css"  crossorigin="anonymous">
    
    
    
    </head><body>
        <div class="content">
            <div class="page-wrapper toggled">
<nav id="sidebar" class="sidebar-wrapper">
    <div class="sidebar-brand">
        <a href='../../../overview/index.html' aria-label="HomePage" alt="HomePage">
            
               <svg width="232" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 232 20">
  <g fill="none" fill-rule="evenodd">
    <text 
      x="50%" 
      y="50%" 
      font-family="Arial, sans-serif" 
      font-size="18" 
      font-weight="bold" 
      fill="#000" 
      text-anchor="middle" 
      dominant-baseline="middle">
      VFORM
    </text>
  </g>
</svg>
            
        </a>
    </div>
    <div class="sidebar-content" style="height: calc(100% - 131px);">
        <ul class="sidebar-menu">
            
                
                
                    
                        
                        <li class="">
                            <a class="sidebar-root-link" href="../../../overview/index.html">
                                <i class="material-icons me-2">dataset</i>
                                
                                文档中心
                            </a>
                        </li>
                    
                
                    
                    
                        <li class="sidebar-dropdown  ">
                            <button class="btn">
                                <i class="material-icons me-2">article</i>
                                产品动向
                            </button>
                            <div class="sidebar-submenu ">
                                <ul>
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    公告
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../announcement/bulletin/bulletins/index.html">【2024年01月03日】MemFire Cloud应用开发正式推出计费套餐</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../../announcement/history/index.html">产品动态</a></li>
                                        
                                    
                                </ul>
                            </div>
                        </li>
                    
                
                    
                    
                        <li class="sidebar-dropdown  ">
                            <button class="btn">
                                <i class="material-icons me-2">deployed_code</i>
                                应用开发
                            </button>
                            <div class="sidebar-submenu ">
                                <ul>
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    概述
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/overview/overview/index.html">介绍</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/overview/features/index.html">功能</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/overview/architecture/index.html">架构</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    购买指南
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/purchase/price/index.html">价格文档</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/purchase/package/index.html">包年包月套餐说明</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/purchase/arrears/index.html">欠费说明</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/purchase/unsubscribe/index.html">退订说明</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/purchase/qa/index.html">计费相关问题</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    快速入门
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-vue-3/index.html">快速入门: Vue</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-react/index.html">快速入门: React</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-flutter/index.html">快速入门: Flutter</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-nextjs/index.html">快速入门: Next.js</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-angular/index.html">快速入门: Angular</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-kotlin/index.html">快速入门: Android Kotlin</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-nuxt-3/index.html">快速入门: Nuxt 3</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-svelte/index.html">快速入门: Svelte</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-ionic-vue/index.html">快速入门: Ionic Vue</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-expo/index.html">快速入门: Expo</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-ionic-angular/index.html">快速入门: Ionic Angular</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-ionic-react/index.html">快速入门: Ionic React</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-redwoodjs/index.html">快速入门: RedwoodJS</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-solidjs/index.html">快速入门: SolidJS</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/quickstart/with-sveltekit/index.html">快速入门: SvelteKit</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    开发指南
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        认证
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/redirect-urls/index.html">重定向 URL</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/native-mobile-deep-linking/index.html">原生移动深度链接</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-captcha/index.html">启用Captcha保护</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/rate-limiting/index.html">速率限制</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            快速开始
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-getting-start/nextjs/index.html">Next.js 设置微信扫码登录身份验证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-getting-start/vue/index.html">vue 设置微信扫码登录身份验证</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            身份验证
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/auth-email/index.html">使用电子邮件登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/phoneauth/index.html">手机登录认证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/wechatauth/index.html">微信小程序登录认证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/wechatappauth/index.html">微信移动应用授权登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/wechatqrauth/index.html">微信网站应用扫码登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/auth-magic-link/index.html">使用Magic Link登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/auth-apple/index.html">使用Apple登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/auth-github/index.html">使用GitHub登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/auth-gitlab/index.html">使用GitLab登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/authentication/auth-email-templates/index.html">电子邮件模板</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            授权
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/mandates/row-level-security/index.html">行级别安全性</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/mandates/row-level-security2/index.html">RLS使用教程</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/mandates/managing-user-data/index.html">管理用户数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/mandates/server-side-rendering/index.html">服务器端渲染</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/mandates/auth-mfa/index.html">多因素身份验证</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证帮助程序
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-helpers/auth-helpers/index.html">身份验证帮助程序</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-helpers/auth-ui/index.html">身份验证UI</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-helpers/nextjs/index.html">使用Next.js进行Supabase认证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-helpers/sveltekit/index.html">使用SveltKit进行Supabase认证</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-helpers/remix/index.html">Supabase Remix认证</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            深层探索
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-deep-dive/auth-deep-dive-jwts/index.html">第一部分:JWTS</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-deep-dive/auth-row-level-security/index.html">第二部分:行级安全</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-deep-dive/auth-policies/index.html">第三部分:策略</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-deep-dive/auth-gotrue/index.html">第四部分: GoTrue</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/auth/auth-deep-dive/auth-google-oauth/index.html">第五部分: Google Oauth</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        数据库
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/database/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/connecting-to-postgres/index.html">数据库连接</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/associated-query/index.html">关联查询</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/functions/index.html">数据库函数</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/tables/index.html">表格和数据</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/webhooks/index.html">数据库 Webhooks</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/compute-add-ons/index.html">计算附加组件</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            扩展
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/extensions/index.html">总览</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/http/index.html">http: RESTful客户端</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/pgcron/index.html">pg_cron: 作业调度</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/index_advisor/index.html">index-advisor: 查询优化</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/pg_graphql/index.html">pg_graphql: 为PostgreSQL提供GraphQL功能</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/pgvector/index.html">pgvector: 嵌入向量和向量相似性</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/pgnet/index.html">pg_net: 异步网络</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/pgtap/index.html">pgTAP:单元测试</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/plv8/index.html">plv8: JavaScript语言</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/extensions/uuid-ossp/index.html">uuid-ossp: 唯一标识符</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            配置
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/setting/timeouts/index.html">超时</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/setting/replication/index.html">复制</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/setting/managing-passwords/index.html">Passwords</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/setting/managing-timezones/index.html">时区</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/setting/query-optimization/index.html">查询优化</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            FDW
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/wrappers/overview/index.html">外部数据包装器(FDW)</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/wrappers/airtable/index.html">Airtable</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/wrappers/s3/index.html">AWS S3</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/wrappers/bigquery/index.html">BigQuery</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/wrappers/clickhouse/index.html">ClickHouse</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/wrappers/firebase/index.html">Firebase</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/wrappers/logflare/index.html">Logflare</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/database/wrappers/stripe/index.html">Stripe</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        无服务器API
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/api/api/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/api/quickstart/index.html">2 分钟构建 API 路由</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/api/generating-types/index.html">生成类型</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/api/graphiql/index.html">GraphQL 介绍</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/api/postman/index.html">使用Postman访问数据</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/api/curl/index.html">使用cURL工具访问数据</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/api/securing-your-api/index.html">开始使用</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/api/creating-routes/index.html">创建 API 路由</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        云函数
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/functions/overview/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/functions/function-management/index.html">管理函数</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/functions/code-development/index.html">代码开发</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/functions/fn-local-test/index.html">云函数本地调试</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/functions/variable/index.html">环境变量</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            函数示例
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/functions/functionexample/helloworld/index.html">helloworld</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/functions/functionexample/wechatpay/index.html">wechatpay</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/functions/functionexample/raffle/index.html">抽奖示例</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        实时数据库
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/realtime/index.html">实时</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/quickstart/index.html">实时快速入门</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/postgres-cdc/index.html">Postgres CDC</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/rate-limits/index.html">实时速率限制</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/concepts/index.html">实时概念</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            用法
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/usage/broadcast/index.html">广播</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/usage/presence/index.html">Presence </a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            指南
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/guides/client-side-throttling/index.html">限制消息</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/guides/postgres-changes/index.html">Postgres 更改</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/guides/realtime-with-nextjs/index.html">将 Realtime 与 Next.js 结合使用</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/guides/subscribing-to-database-changes/index.html">订阅数据库更改</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            深入了解
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/deep-dive/architecture/index.html">实时架构</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/deep-dive/bring-your-own-database/index.html">自带数据库</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/deep-dive/protocol/index.html">实时协议</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/realtime/deep-dive/quotas/index.html">实时配额</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        对象存储
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/storage/storage/index.html">概述</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/storage/storage-cdn/index.html">存储CDN</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        AI 和 Vectors
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/ai/ai/index.html">总览</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        静态托管
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/hosting/static-hosting/index.html">静态托管</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/hosting/static-start/index.html">快速开始</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/hosting/static-domain/index.html">自定义域名</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/development_guide/hosting/real-name-authentication/index.html">实名认证</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    SDK文档
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        JavaScript
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            开始
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/start/javascript/index.html">JavaScript库</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/start/installing/index.html">安装</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/start/initializing/index.html">初始化客户端</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/start/typescript-support/index.html">支持Typescript</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/start/release-notes/index.html">版本说明</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/database/select/index.html">Select 查询</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/database/insert/index.html">Insert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/database/update/index.html">Update 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/database/upsert/index.html">Upsert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/database/delete/index.html">Delete 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/database/rpc/index.html">调用Postgres函数</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/database/filter/index.html">过滤器</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/database/modifier/index.html">修改器</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-api/index.html">概述</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-signup/index.html">signUp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-signinwithpassword/index.html">signInWithPassword()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-signinwithotp/index.html">signInWithOtp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-signinwithoauth/index.html">signInWithOAuth()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-signout/index.html">signOut()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-resetpasswordforemail/index.html">resetPasswordForEmail()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-verifyotp/index.html">通过 OTP 进行验证和登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-getsession/index.html">getSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-refreshsession/index.html">refreshSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-getuser/index.html">getUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-updateuser/index.html">updateUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-setsession/index.html">setSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth/auth-onauthstatechange/index.html">onAuthStateChange()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证（仅限服务端）
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth-admin/supabase-auth-admin-api/index.html">概览</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth-admin/auth-admin-getuserbyid/index.html">getUserById()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth-admin/auth-admin-listusers/index.html">listUsers()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth-admin/auth-admin-createuser/index.html">createUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth-admin/auth-admin-deleteuser/index.html">deleteUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth-admin/auth-admin-inviteuserbyemail/index.html">inviteUserByEmail()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth-admin/auth-admin-generatelink/index.html">generateLink()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/auth-admin/auth-admin-updateuserbyid/index.html">updateUserById()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            函数
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/function/invoke/index.html">invoke()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            实时数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/realtime/subscribe/index.html">on().subscribe()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/realtime/removechannel/index.html">removeChannel()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/realtime/removeallchannels/index.html">removeAllChannels()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/realtime/getchannels/index.html">getChannels()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            对象存储
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-createbucket/index.html">createBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-deletebucket/index.html">deleteBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-download/index.html">from.download()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-upload/index.html">from.upload()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-update/index.html">from.update()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-remove/index.html">from.remove()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-list/index.html">from.list()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-move/index.html">from.move()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-copy/index.html">from.copy()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-createsignedurl/index.html">from.createSignedUrl()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-createsignedurls/index.html">from.createSignedUrls()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-from-getpublicurl/index.html">from.getPublicUrl()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-emptybucket/index.html">emptyBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-getbucket/index.html">getBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-listbuckets/index.html">listBuckets()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/javascript/storage/storage-updatebucket/index.html">updateBucket()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        Flutter
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            开始
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/start/dart/index.html">Flutter库</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/start/initializing/index.html">初始化</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/start/installing/index.html">安装</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/start/upgrade-guide/index.html">更新</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/database/select/index.html">Select 查询</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/database/insert/index.html">Insert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/database/update/index.html">Update 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/database/upsert/index.html">Upsert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/database/delete/index.html">Delete 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/database/rpc/index.html">存储程序: rpc()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/database/filter/index.html">过滤器</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/database/modifier/index.html">修改器</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-signup/index.html">signUp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-signinwithpassword/index.html">signInWithPassword()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-signinwithotp/index.html">signInWithOtp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-signinwithoauth/index.html">signInWithOAuth()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-signout/index.html">signOut()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-verifyotp/index.html">verifyOtp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-currentsession/index.html">currentSession</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-currentuser/index.html">currentUser</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-updateuser/index.html">updateUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-onauthstatechange/index.html">onAuthStateChange()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/auth/auth-resetpasswordforemail/index.html">resetPasswordForEmail()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            函数
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/function/invoke/index.html">待补充</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            实时数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/realtime/stream/index.html">stream()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/realtime/subscribe/index.html">on().subscribe()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/realtime/removechannel/index.html">removeChannel()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/realtime/removeallchannels/index.html">removeAllChannels()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/realtime/getchannels/index.html">getChannels()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            对象存储
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-createbucket/index.html">createBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-getbucket/index.html">getBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-listbuckets/index.html">listBuckets()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-updatebucket/index.html">updateBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-deletebucket/index.html">deleteBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-emptybucket/index.html">emptyBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-upload/index.html">from.upload()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-download/index.html">from.download()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-list/index.html">from.list()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-update/index.html">from.update()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-move/index.html">from.move()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-remove/index.html">from.remove()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-createsignedurl/index.html">from.createSignedUrl()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-createsignedurls/index.html">from.createSignedUrls()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/dart/storage/storage-from-getpublicurl/index.html">from.getPublicUrl()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        微信小程序
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            开始
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/start/wechat/index.html">微信小程序客户端</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/start/installing/index.html">安装</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/start/initializing/index.html">初始化客户端</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/start/typescript-support/index.html">支持Typescript</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/start/release-notes/index.html">版本说明</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/database/select/index.html">Select 查询</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/database/insert/index.html">Insert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/database/update/index.html">Update 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/database/upsert/index.html">Upsert 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/database/delete/index.html">Delete 数据</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/database/rpc/index.html">调用Postgres函数</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/database/filter/index.html">过滤器</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/database/modifier/index.html">修改器</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-api/index.html">概述</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-signinwithwechat/index.html">signInWithWechat()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-wechatbindphone/index.html">getUnlimitedQRCode()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-getunlimitedqrcode/index.html">signInWithWechat()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-wechatbindaccount/index.html">wechatBindAccount()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-updateuser/index.html">updateUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-signup/index.html">signUp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-signinwithpassword/index.html">signInWithPassword()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-signinwithotp/index.html">signInWithOtp()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-signinwithoauth/index.html">signInWithOAuth()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-signout/index.html">signOut()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-verifyotp/index.html">通过 OTP 进行验证和登录</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-getsession/index.html">getSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-refreshsession/index.html">refreshSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-getuser/index.html">getUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-setsession/index.html">setSession()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-onauthstatechange/index.html">onAuthStateChange()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth/auth-resetpasswordforemail/index.html">resetPasswordForEmail()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            认证（仅限服务端）
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth-admin/auth-admin-listusers/index.html">listUsers()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth-admin/supabase-auth-admin-api/index.html">概览</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth-admin/auth-admin-createuser/index.html">createUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth-admin/auth-admin-deleteuser/index.html">deleteUser()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth-admin/auth-admin-generatelink/index.html">generateLink()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth-admin/auth-admin-inviteuserbyemail/index.html">inviteUserByEmail()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth-admin/auth-admin-getuserbyid/index.html">getUserById()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/auth-admin/auth-admin-updateuserbyid/index.html">updateUserById()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            函数
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/function/invoke/index.html">invoke()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            实时数据库
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/realtime/subscribe/index.html">on().subscribe()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/realtime/removechannel/index.html">removeChannel()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/realtime/removeallchannels/index.html">removeAllChannels()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/realtime/getchannels/index.html">getChannels()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class="sidebar-dropdown nested  ">
                                                                                        <button class="btn">
                                                                                            
                                                                                            对象存储
                                                                                        </button>
                                                                                        <div class="sidebar-submenu ">
                                                                                            <ul>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-createbucket/index.html">createBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-getbucket/index.html">getBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-listbuckets/index.html">listBuckets()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-updatebucket/index.html">updateBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-deletebucket/index.html">deleteBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-emptybucket/index.html">emptyBucket()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-upload/index.html">from.upload()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-download/index.html">from.download()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-list/index.html">from.list()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-update/index.html">from.update()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-move/index.html">from.move()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-copy/index.html">from.copy()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-remove/index.html">from.remove()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-createsignedurl/index.html">from.createSignedUrl()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-createsignedurls/index.html">from.createSignedUrls()</a></li>
                                                                                                
                                                                                                    
                                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/sdkdocs/wechatsdk/storage/storage-from-getpublicurl/index.html">from.getPublicUrl()</a></li>
                                                                                                
                                                                                            </ul>
                                                                                        </div>
                                                                                    </li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    最佳实践
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../../app/example/scaffold/index.html">前端框架的脚手架</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        微信小程序
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/example/wechat/timetable/index.html">Super课表小程序</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/example/wechat/hellobbs/index.html">BBS论坛小程序</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/example/wechat/notclickwhite/index.html">别踩白块游戏小程序</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/example/wechat/wechatroom/index.html">微信小程序聊天室</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="sidebar-dropdown nested  ">
                                                                    <button class="btn">
                                                                        
                                                                        Web
                                                                    </button>
                                                                    <div class="sidebar-submenu ">
                                                                        <ul>
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/example/web/postsforum/index.html">Posts社交网络论坛</a></li>
                                                                                
                                                                            
                                                                                
                                                                                
                                                                                    <li class=" "><a class="sidebar-nested-link" href="../../../app/example/web/playground/index.html">实时游戏场</a></li>
                                                                                
                                                                            
                                                                        </ul>
                                                                    </div>
                                                                </li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                </ul>
                            </div>
                        </li>
                    
                
                    
                    
                        <li class="sidebar-dropdown  current active">
                            <button class="btn">
                                <i class="material-icons me-2">database</i>
                                云数据库
                            </button>
                            <div class="sidebar-submenu d-block">
                                <ul>
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../db-introduction/index.html">介绍</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../database-management/index.html">数据库管理</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../account-management/index.html">账号管理</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../backup-and-recovery/index.html">备份恢复</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../online-sql-editor/index.html">在线SQL编辑器</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../client-connection/index.html">客户端工具</a></li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../introduction-to-sql-operation/index.html">SQL操作入门</a></li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  ">
                                                <button class="btn">
                                                    
                                                    开发示例
                                                </button>
                                                <div class="sidebar-submenu ">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/python-example/index.html">Python2示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/python3-example/index.html">Python3示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/java-example/index.html">Java示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/golang-example/index.html">Golang示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/spring-example/index.html">Spring示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/node-example/index.html">Node示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/c%2b%2b-example/index.html">C&#43;&#43;示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/c-example/index.html">C#示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/c2-example/index.html">C示例</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../../example/development-example/index.html"></a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                        
                                        
                                            <li class=" "><a class="sidebar-nested-link" href="../../memfiredb-data-migration/index.html">数据迁移</a></li>
                                        
                                    
                                        
                                        
                                            <li class="sidebar-dropdown nested  current active">
                                                <button class="btn">
                                                    
                                                    参考指南
                                                </button>
                                                <div class="sidebar-submenu d-block">
                                                    <ul>
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../compatibility/index.html">兼容性说明</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../keyword/index.html">关键字</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../data-type/index.html">数据类型</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class="current "><a class="sidebar-nested-link" href="index.html">SQL语法</a></li>
                                                            
                                                        
                                                            
                                                            
                                                                <li class=" "><a class="sidebar-nested-link" href="../functions-and-operations/index.html">函数与操作</a></li>
                                                            
                                                        
                                                    </ul>
                                                </div>
                                            </li>
                                        
                                    
                                </ul>
                            </div>
                        </li>
                    
                
                    
                        
                        <li class="">
                            <a class="sidebar-root-link" href="../../../contactus/index.html">
                                <i class="material-icons me-2">article</i>
                                
                                联系我们
                            </a>
                        </li>
                    
                
                    
                        
                        <li class="">
                            <a class="sidebar-root-link" href="../../../frequently-asked-questions/index.html">
                                <i class="material-icons me-2">quiz</i>
                                
                                常见问题解答（FAQ）
                            </a>
                        </li>
                    
                
            
        </ul>
        
    </div>
    
        <ul class="sidebar-footer list-unstyled mb-0">
            
        </ul>
    
</nav>

                    <main class="page-content bg-transparent">
                        
<div id="top-header" class="top-header d-print-none">
    <div class="header-bar d-flex justify-content-between">
        <div class="d-flex align-items-center">
            <a href='https://docs.memfiredb.com/' class="logo-icon me-3" aria-label="HomePage" alt="HomePage">
                <div class="small">
                    
                            <?xml version="1.0" encoding="UTF-8"?>
<svg width="99px" height="112px" viewBox="0 0 99 112" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <title>MemFireDB备份 6</title>
    <defs>
        <linearGradient x1="49.9999885%" y1="98.082503%" x2="49.9999885%" y2="0.766550128%" id="linearGradient-1">
            <stop stop-color="#ED1C23" offset="0%"></stop>
            <stop stop-color="#FBAF3B" offset="100%"></stop>
        </linearGradient>
    </defs>
    <g id="定稿" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <g id="MemFireDB备份-6">
            <polygon id="Fill-1" fill="#F9AE7C" points="25.9728553 40.7912363 47.4268317 0.00591833831 1.15453123 26.7215251"></polygon>
            <polygon id="Fill-3" fill="#F9AE7C" points="97.4213117 26.7267606 51.1285247 0.000910513587 72.4242993 40.8351686"></polygon>
            <polygon id="Fill-5" fill="#F9904A" points="24.8347133 42.7618153 0.000455256793 28.682999 0.000455256793 82.1608764"></polygon>
            <polygon id="Fill-7" fill="url(#linearGradient-1)" points="27.6634514 42.4662399 49.279044 109.05096 70.7296059 42.507213 49.2779058 1.3747617"></polygon>
            <polygon id="Fill-9" fill="#F9904A" points="98.5660549 28.6951771 73.5622137 42.8047233 98.5660549 82.1719163"></polygon>
            <polygon id="Fill-13" fill="#FB6D33" points="72.2987623 45.061545 50.7514582 111.900071 97.579172 84.8646465"></polygon>
            <polygon id="Fill-15" fill="#FB6D33" points="26.1006687 45.0226206 0.987565799 84.8644188 47.8095888 111.898705"></polygon>
            <path d="M60.0737516,38.507213 C59.3168872,35.669825 57.0462939,33.3514298 57.0462939,33.3514298 C57.0462939,33.3514298 57.0804382,35.8849338 56.2894295,37.513615 C55.4847631,39.1696116 53.8765685,40.3054773 53.8765685,40.3054773 C53.8765685,40.3054773 56.1016361,33.8840802 54.2715038,30.1247973 C52.0259496,25.5073552 49.1771803,23.3357803 49.1771803,23.3357803 C49.1771803,23.3357803 50.1070423,28.1319107 48.6240432,31.5065016 C47.1672215,34.8264618 42.8058614,36.7260208 40.7241997,38.7132167 C39.1865699,40.1791435 38.0814341,43.0711623 37.6068289,44.4847347 C37.5715465,44.5883056 37.560165,44.6918765 37.5533362,44.7943093 C37.584066,43.9816759 37.8890881,39.8024186 40.9654858,37.4293925 C43.8404325,35.2111538 41.2431925,30.3478731 41.2431925,30.3478731 C41.2431925,30.3478731 41.7212121,32.5638355 40.9939394,34.1401622 C40.2655285,35.7153507 38.7187936,36.5962726 38.0154218,38.259098 C37.3883056,39.7409589 37.5203301,44.1432921 37.5453692,44.8409731 C37.5453692,44.8591834 37.5476455,44.8762555 37.5476455,44.8921895 C37.5476455,44.9263338 37.5487836,44.9456822 37.5487836,44.9456822 L37.5487836,44.9115379 C37.5590269,45.2655001 37.7138142,45.6080808 37.9972116,45.8448143 L48.3713757,55.6442168 C48.8380139,56.0323232 49.5163466,56.0334614 49.9841229,55.6476312 L60.5938825,45.7105136 C60.9034571,45.4544316 61.0719021,45.0686015 61.0457249,44.6656992 C60.9546735,43.2282259 60.5699815,40.3692133 60.0737516,38.507213" id="Fill-17" fill="#FFFFFF"></path>
        </g>
    </g>
</svg>
                    
                </div>
                <div class="big">
                    
                           <svg width="232" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 232 20">
  <g fill="none" fill-rule="evenodd">
    <text 
      x="50%" 
      y="50%" 
      font-family="Arial, sans-serif" 
      font-size="18" 
      font-weight="bold" 
      fill="#000" 
      text-anchor="middle" 
      dominant-baseline="middle">
      VFORM
    </text>
  </g>
</svg>
                    
                </div>
            </a>
            <button id="close-sidebar" class="btn btn-icon btn-soft">
                <span class="material-icons size-20 menu-icon align-middle">menu</span>
            </button>
            
            </div>

        <div class="d-flex align-items-center">
            <ul class="list-unstyled mb-0">
                
            </ul>
            <a  class="btn btn-icon btn-default ms-4"  type="button" href="https://memfiredb.com/"  target="_blank" >官网</a>
            <a  class="btn btn-icon btn-default ms-4" type="button" href="https://community.memfiredb.com/"  target="_blank"  >论坛</a>
            <a  class="btn btn-icon btn-default ms-4" type="button" href="https://cloud.memfiredb.com/auth/login"  target="_blank"  >登录</a>
            <button id="mode" class="btn btn-icon btn-default ms-2" type="button" aria-label="Toggle user interface mode">
                <span class="toggle-dark">
                    <svg xmlns="http://www.w3.org/2000/svg" height="30" width="30" viewBox="0 0 48 48" fill="currentColor">
                        <title>Enable dark mode</title>
                        <path d="M24 42q-7.5 0-12.75-5.25T6 24q0-7.5 5.25-12.75T24 6q.4 0 .85.025.45.025 1.15.075-1.8 1.6-2.8 3.95-1 2.35-1 4.95 0 4.5 3.15 7.65Q28.5 25.8 33 25.8q2.6 0 4.95-.925T41.9 22.3q.05.6.075.975Q42 23.65 42 24q0 7.5-5.25 12.75T24 42Zm0-3q5.45 0 9.5-3.375t5.05-7.925q-1.25.55-2.675.825Q34.45 28.8 33 28.8q-5.75 0-9.775-4.025T19.2 15q0-1.2.25-2.575.25-1.375.9-3.125-4.9 1.35-8.125 5.475Q9 18.9 9 24q0 6.25 4.375 10.625T24 39Zm-.2-14.85Z"/>
                    </svg>
                </span>
                <span class="toggle-light">
                    <svg xmlns="http://www.w3.org/2000/svg" height="30" width="30" viewBox="0 0 48 48" fill="currentColor">
                        <title>Enable light mode</title>
                        <path d="M24 31q2.9 0 4.95-2.05Q31 26.9 31 24q0-2.9-2.05-4.95Q26.9 17 24 17q-2.9 0-4.95 2.05Q17 21.1 17 24q0 2.9 2.05 4.95Q21.1 31 24 31Zm0 3q-4.15 0-7.075-2.925T14 24q0-4.15 2.925-7.075T24 14q4.15 0 7.075 2.925T34 24q0 4.15-2.925 7.075T24 34ZM3.5 25.5q-.65 0-1.075-.425Q2 24.65 2 24q0-.65.425-1.075Q2.85 22.5 3.5 22.5h5q.65 0 1.075.425Q10 23.35 10 24q0 .65-.425 1.075-.425.425-1.075.425Zm36 0q-.65 0-1.075-.425Q38 24.65 38 24q0-.65.425-1.075.425-.425 1.075-.425h5q.65 0 1.075.425Q46 23.35 46 24q0 .65-.425 1.075-.425.425-1.075.425ZM24 10q-.65 0-1.075-.425Q22.5 9.15 22.5 8.5v-5q0-.65.425-1.075Q23.35 2 24 2q.65 0 1.075.425.425.425.425 1.075v5q0 .65-.425 1.075Q24.65 10 24 10Zm0 36q-.65 0-1.075-.425-.425-.425-.425-1.075v-5q0-.65.425-1.075Q23.35 38 24 38q.65 0 1.075.425.425.425.425 1.075v5q0 .65-.425 1.075Q24.65 46 24 46ZM12 14.1l-2.85-2.8q-.45-.45-.425-1.075.025-.625.425-1.075.45-.45 1.075-.45t1.075.45L14.1 12q.4.45.4 1.05 0 .6-.4 1-.4.45-1.025.45-.625 0-1.075-.4Zm24.7 24.75L33.9 36q-.4-.45-.4-1.075t.45-1.025q.4-.45 1-.45t1.05.45l2.85 2.8q.45.45.425 1.075-.025.625-.425 1.075-.45.45-1.075.45t-1.075-.45ZM33.9 14.1q-.45-.45-.45-1.05 0-.6.45-1.05l2.8-2.85q.45-.45 1.075-.425.625.025 1.075.425.45.45.45 1.075t-.45 1.075L36 14.1q-.4.4-1.025.4-.625 0-1.075-.4ZM9.15 38.85q-.45-.45-.45-1.075t.45-1.075L12 33.9q.45-.45 1.05-.45.6 0 1.05.45.45.45.45 1.05 0 .6-.45 1.05l-2.8 2.85q-.45.45-1.075.425-.625-.025-1.075-.425ZM24 24Z"/>
                    </svg>
                </span>
            </button>
            
        </div>
    </div>
    
    
    
</div>

                            <div class="container-fluid">
                                <div class="layout-spacing">
                                    
                                        <div class="d-md-flex justify-content-between align-items-center"><nav aria-label="breadcrumb" class="d-inline-block pb-2 mt-1 mt-sm-0">
    <ul id="breadcrumbs" class="breadcrumb bg-transparent mb-0" itemscope itemtype="https://schema.org/BreadcrumbList">
        
            
                <li class="breadcrumb-item text-capitalize active" aria-current="page" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    <a itemprop="item" href="../../../index.html">
                        <i class="material-icons size-20 align-text-bottom" itemprop="name">Home</i>
                    </a>
                    <meta itemprop="position" content='1' />
                </li>
            
            
                <li class="breadcrumb-item text-capitalize" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    <a itemprop="item" href="../../index.html">
                        <span itemprop="name">云数据库</span>
                    </a>
                    <meta itemprop="position" content='2' />
                </li>
            
            
                <li class="breadcrumb-item text-capitalize" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    <a itemprop="item" href="../index.html">
                        <span itemprop="name">参考指南</span>
                    </a>
                    <meta itemprop="position" content='3' />
                </li>
            
        
            <li class="breadcrumb-item text-capitalize active" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                <span itemprop="name">SQL语法</span>
                <meta itemprop="position" content='4' />
            </li>
        
    </ul>
</nav></div>
                                    
                                    <div class="row flex-xl-nowrap">
                                        
                                        <div class="docs-toc col-xl-3    d-xl-block"><toc>
    <div class="fw-bold text-uppercase mb-2">本页</div>
    <nav id="toc">
  <ul>
    <li>
      <ul>
        <li><a href="#数据定义语言ddl">数据定义语言（DDL）</a></li>
        <li><a href="#数据操作语言dml">数据操作语言（DML）</a></li>
        <li><a href="#数据控制语言dcl">数据控制语言（DCL）</a></li>
        <li><a href="#事务控制语言tcl">事务控制语言（TCL）</a></li>
        <li><a href="#会话和系统控制">会话和系统控制</a></li>
        <li><a href="#性能控制">性能控制</a></li>
        <li><a href="#其他声明">其他声明</a></li>
        <li><a href="#abort">ABORT</a></li>
        <li><a href="#alter-database">ALTER DATABASE</a></li>
        <li><a href="#alter-default-privileges">ALTER DEFAULT PRIVILEGES</a></li>
        <li><a href="#alter-domain">ALTER DOMAIN</a></li>
        <li><a href="#alter-group">ALTER GROUP</a></li>
        <li><a href="#alter-policy">ALTER POLICY</a></li>
        <li><a href="#alter-role">ALTER ROLE</a></li>
        <li><a href="#alter-sequence">ALTER SEQUENCE</a></li>
        <li><a href="#alter-table">ALTER TABLE</a></li>
        <li><a href="#alter-user">ALTER USER</a></li>
        <li><a href="#begin">BEGIN</a></li>
        <li><a href="#comment">COMMENT</a></li>
        <li><a href="#commit">COMMIT</a></li>
        <li><a href="#copy">COPY</a></li>
        <li><a href="#create-aggregate">CREATE AGGREGATE</a></li>
        <li><a href="#create-cast">CREATE CAST</a></li>
        <li><a href="#create-database">CREATE DATABASE</a></li>
        <li><a href="#create-domain">CREATE DOMAIN</a></li>
        <li><a href="#create-extension">CREATE EXTENSION</a></li>
        <li><a href="#create-function">CREATE FUNCTION</a></li>
        <li><a href="#create-group">CREATE GROUP</a></li>
        <li><a href="#create-index">CREATE INDEX</a></li>
        <li><a href="#create-operator">CREATE OPERATOR</a></li>
        <li><a href="#create-operator-class">CREATE OPERATOR CLASS</a></li>
        <li><a href="#create-policy">CREATE POLICY</a></li>
        <li><a href="#create-procedure">CREATE PROCEDURE</a></li>
        <li><a href="#create-role">CREATE ROLE</a></li>
        <li><a href="#create-rule">CREATE RULE</a></li>
        <li><a href="#create-schema">CREATE SCHEMA</a></li>
        <li><a href="#create-sequence">CREATE SEQUENCE</a></li>
        <li><a href="#create-table">CREATE TABLE</a></li>
        <li><a href="#create-table-as">CREATE TABLE AS</a></li>
        <li><a href="#create-trigger">CREATE TRIGGER</a></li>
        <li><a href="#create-type">CREATE TYPE</a></li>
        <li><a href="#create-user">CREATE USER</a></li>
        <li><a href="#create-view">CREATE VIEW</a></li>
        <li><a href="#dellocate">DELLOCATE</a></li>
        <li><a href="#delete">DELETE</a></li>
        <li><a href="#do">DO</a></li>
        <li><a href="#drop-aggregate">DROP AGGREGATE</a></li>
        <li><a href="#drop-cast">DROP CAST</a></li>
        <li><a href="#drop-database">DROP DATABASE</a></li>
        <li><a href="#drop-domain">DROP DOMAIN</a></li>
        <li><a href="#drop-extension">DROP EXTENSION</a></li>
        <li><a href="#drop-function">DROP FUNCTION</a></li>
        <li><a href="#drop-group">DROP GROUP</a></li>
        <li><a href="#drop-operator">DROP OPERATOR</a></li>
        <li><a href="#drop-operator-class">DROP OPERATOR CLASS</a></li>
        <li><a href="#drop-owned">DROP OWNED</a></li>
        <li><a href="#drop-policy">DROP POLICY</a></li>
        <li><a href="#drop-procedure">DROP PROCEDURE</a></li>
        <li><a href="#drop-role">DROP ROLE</a></li>
        <li><a href="#drop-rule">DROP RULE</a></li>
        <li><a href="#drop-sequence">DROP SEQUENCE</a></li>
        <li><a href="#drop-table">DROP TABLE</a></li>
        <li><a href="#drop-trigger">DROP TRIGGER</a></li>
        <li><a href="#drop-type">DROP TYPE</a></li>
        <li><a href="#drop-user">DROP USER</a></li>
        <li><a href="#end">END</a></li>
        <li><a href="#execute">EXECUTE</a></li>
        <li><a href="#explain">EXPLAIN</a></li>
        <li><a href="#grant">GRANT</a></li>
        <li><a href="#insert">INSERT</a></li>
        <li><a href="#lock">LOCK</a></li>
        <li><a href="#prepare">PREPARE</a></li>
        <li><a href="#reassign-owned">REASSIGN OWNED</a></li>
        <li><a href="#reset">RESET</a></li>
        <li><a href="#revoke">REVOKE</a></li>
        <li><a href="#rollback">ROLLBACK</a></li>
        <li><a href="#select">SELECT</a></li>
        <li><a href="#set">SET</a></li>
        <li><a href="#set-constraints">SET CONSTRAINTS</a></li>
        <li><a href="#set-role">SET ROLE</a></li>
        <li><a href="#set-session-authorization">SET SESSION AUTHORIZATION</a></li>
        <li><a href="#set-transaction">SET TRANSACTION</a></li>
        <li><a href="#show">SHOW</a></li>
        <li><a href="#show-transaction">SHOW TRANSACTION</a></li>
        <li><a href="#truncate">TRUNCATE</a></li>
        <li><a href="#update">UPDATE</a></li>
      </ul>
    </li>
  </ul>
</nav>
    </toc></div>
                                        
                                        
                                        <div class="docs-toc-mobile    d-print-none d-xl-none">
                                            <button id="toc-dropdown-btn" class="btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-offset="0,0" aria-expanded="false">
                                                Table of Contents
                                            </button>
<nav id="toc-mobile">
  <ul class="dropdown-menu">
    <li>
      <ul>
        <li><a href="#数据定义语言ddl">数据定义语言（DDL）</a></li>
        <li><a href="#数据操作语言dml">数据操作语言（DML）</a></li>
        <li><a href="#数据控制语言dcl">数据控制语言（DCL）</a></li>
        <li><a href="#事务控制语言tcl">事务控制语言（TCL）</a></li>
        <li><a href="#会话和系统控制">会话和系统控制</a></li>
        <li><a href="#性能控制">性能控制</a></li>
        <li><a href="#其他声明">其他声明</a></li>
        <li><a href="#abort">ABORT</a></li>
        <li><a href="#alter-database">ALTER DATABASE</a></li>
        <li><a href="#alter-default-privileges">ALTER DEFAULT PRIVILEGES</a></li>
        <li><a href="#alter-domain">ALTER DOMAIN</a></li>
        <li><a href="#alter-group">ALTER GROUP</a></li>
        <li><a href="#alter-policy">ALTER POLICY</a></li>
        <li><a href="#alter-role">ALTER ROLE</a></li>
        <li><a href="#alter-sequence">ALTER SEQUENCE</a></li>
        <li><a href="#alter-table">ALTER TABLE</a></li>
        <li><a href="#alter-user">ALTER USER</a></li>
        <li><a href="#begin">BEGIN</a></li>
        <li><a href="#comment">COMMENT</a></li>
        <li><a href="#commit">COMMIT</a></li>
        <li><a href="#copy">COPY</a></li>
        <li><a href="#create-aggregate">CREATE AGGREGATE</a></li>
        <li><a href="#create-cast">CREATE CAST</a></li>
        <li><a href="#create-database">CREATE DATABASE</a></li>
        <li><a href="#create-domain">CREATE DOMAIN</a></li>
        <li><a href="#create-extension">CREATE EXTENSION</a></li>
        <li><a href="#create-function">CREATE FUNCTION</a></li>
        <li><a href="#create-group">CREATE GROUP</a></li>
        <li><a href="#create-index">CREATE INDEX</a></li>
        <li><a href="#create-operator">CREATE OPERATOR</a></li>
        <li><a href="#create-operator-class">CREATE OPERATOR CLASS</a></li>
        <li><a href="#create-policy">CREATE POLICY</a></li>
        <li><a href="#create-procedure">CREATE PROCEDURE</a></li>
        <li><a href="#create-role">CREATE ROLE</a></li>
        <li><a href="#create-rule">CREATE RULE</a></li>
        <li><a href="#create-schema">CREATE SCHEMA</a></li>
        <li><a href="#create-sequence">CREATE SEQUENCE</a></li>
        <li><a href="#create-table">CREATE TABLE</a></li>
        <li><a href="#create-table-as">CREATE TABLE AS</a></li>
        <li><a href="#create-trigger">CREATE TRIGGER</a></li>
        <li><a href="#create-type">CREATE TYPE</a></li>
        <li><a href="#create-user">CREATE USER</a></li>
        <li><a href="#create-view">CREATE VIEW</a></li>
        <li><a href="#dellocate">DELLOCATE</a></li>
        <li><a href="#delete">DELETE</a></li>
        <li><a href="#do">DO</a></li>
        <li><a href="#drop-aggregate">DROP AGGREGATE</a></li>
        <li><a href="#drop-cast">DROP CAST</a></li>
        <li><a href="#drop-database">DROP DATABASE</a></li>
        <li><a href="#drop-domain">DROP DOMAIN</a></li>
        <li><a href="#drop-extension">DROP EXTENSION</a></li>
        <li><a href="#drop-function">DROP FUNCTION</a></li>
        <li><a href="#drop-group">DROP GROUP</a></li>
        <li><a href="#drop-operator">DROP OPERATOR</a></li>
        <li><a href="#drop-operator-class">DROP OPERATOR CLASS</a></li>
        <li><a href="#drop-owned">DROP OWNED</a></li>
        <li><a href="#drop-policy">DROP POLICY</a></li>
        <li><a href="#drop-procedure">DROP PROCEDURE</a></li>
        <li><a href="#drop-role">DROP ROLE</a></li>
        <li><a href="#drop-rule">DROP RULE</a></li>
        <li><a href="#drop-sequence">DROP SEQUENCE</a></li>
        <li><a href="#drop-table">DROP TABLE</a></li>
        <li><a href="#drop-trigger">DROP TRIGGER</a></li>
        <li><a href="#drop-type">DROP TYPE</a></li>
        <li><a href="#drop-user">DROP USER</a></li>
        <li><a href="#end">END</a></li>
        <li><a href="#execute">EXECUTE</a></li>
        <li><a href="#explain">EXPLAIN</a></li>
        <li><a href="#grant">GRANT</a></li>
        <li><a href="#insert">INSERT</a></li>
        <li><a href="#lock">LOCK</a></li>
        <li><a href="#prepare">PREPARE</a></li>
        <li><a href="#reassign-owned">REASSIGN OWNED</a></li>
        <li><a href="#reset">RESET</a></li>
        <li><a href="#revoke">REVOKE</a></li>
        <li><a href="#rollback">ROLLBACK</a></li>
        <li><a href="#select">SELECT</a></li>
        <li><a href="#set">SET</a></li>
        <li><a href="#set-constraints">SET CONSTRAINTS</a></li>
        <li><a href="#set-role">SET ROLE</a></li>
        <li><a href="#set-session-authorization">SET SESSION AUTHORIZATION</a></li>
        <li><a href="#set-transaction">SET TRANSACTION</a></li>
        <li><a href="#show">SHOW</a></li>
        <li><a href="#show-transaction">SHOW TRANSACTION</a></li>
        <li><a href="#truncate">TRUNCATE</a></li>
        <li><a href="#update">UPDATE</a></li>
      </ul>
    </li>
  </ul>
</nav></div>
                                        <div class="docs-content col-12 col-xl-9 mt-0">
                                            <div class="mb-0 d-flex">
                                                
                                                <h1 class="content-title mb-0">
                                                    SQL语法
                                                    
                                                </h1>
                                            </div>
                                            
                                            <div id="content" class="main-content" data-bs-spy="scroll" data-bs-root-margin="0px 0px -65%" data-bs-target="#toc-mobile">
                                                
    
    <div data-prismjs-copy="" data-prismjs-copy-success="" data-prismjs-copy-error="">
        <p>MemFireDB 结构化查询语言（MSQL）是符合ANSI标准的结构化查询语言。兼容PostgreSQL 11.2版本。MemFireDB复用了PostgresSQL的原生查询层。MemFire支持所有的传统关系模型功能，例如引用完整性（例如外键）、JOIN、分布式事务、部分索引、触发器和存储过程。</p>
<p>MSQL的主要组件包括数据定义语言（DDL）、数据操作语言（DML）和数据控制语言（DCL）。这些组件由多个元素构成，包括数据类型、数据库对象、名称和限定符、表达式和注释。此外MSQL还提供了其他用途的组件，例如系统控制、事务控制和性能调试。</p>







<table class="table table-striped">
<thead>
<tr>
<th>声明</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ABORT</td>
<td>回滚事务</td>
</tr>
<tr>
<td>ALTER DATABASE</td>
<td>更改数据库定义</td>
</tr>
<tr>
<td>ALTER DEFAULT PRIVILEGES</td>
<td>定义默认访问权限</td>
</tr>
<tr>
<td>ALTER DOMAIN</td>
<td>变更网域</td>
</tr>
<tr>
<td>ALTER GROUP</td>
<td>变更群组</td>
</tr>
<tr>
<td>ALTER POLICY</td>
<td>更改行级安全策略</td>
</tr>
<tr>
<td>ALTER ROLE</td>
<td>改变角色</td>
</tr>
<tr>
<td>ALTER SEQUENCE</td>
<td>更改序列定义</td>
</tr>
<tr>
<td>ALTER TABLE</td>
<td>变更表定义</td>
</tr>
<tr>
<td>ALTER USER</td>
<td>更改用户（角色）</td>
</tr>
<tr>
<td>BEGIN</td>
<td>开始交易</td>
</tr>
<tr>
<td>COMMENT</td>
<td>在数据库对象上添加注释</td>
</tr>
<tr>
<td>COMMIT</td>
<td>提交交易</td>
</tr>
<tr>
<td>COPY</td>
<td>在表和文件之间复制数据</td>
</tr>
<tr>
<td>CREATE AGGREGATE</td>
<td>创建一个新的聚合</td>
</tr>
<tr>
<td>CREATE CAST</td>
<td>建立新的类型转换</td>
</tr>
<tr>
<td>CREATE DATABASE</td>
<td>创建一个新的数据库</td>
</tr>
<tr>
<td>CREATE DOMAIN</td>
<td>创建一个新域</td>
</tr>
<tr>
<td>CREATE EXTENSION</td>
<td>加载扩展</td>
</tr>
<tr>
<td>CREATE FUNCTION</td>
<td>创建一个新功能</td>
</tr>
<tr>
<td>CREATE INDEX</td>
<td>创建一个新索引</td>
</tr>
<tr>
<td>CREATE GROUP</td>
<td>创建一个新组（角色）</td>
</tr>
<tr>
<td>CREATE OPERATOR</td>
<td>创建一个新的运算符</td>
</tr>
<tr>
<td>CREATE OPERATOR CLASS</td>
<td>创建一个新的运算符类</td>
</tr>
<tr>
<td>CREATE POLICY</td>
<td>创建一个新的行级安全策略</td>
</tr>
<tr>
<td>CREATE PROCEDURE</td>
<td>创建一个新程序</td>
</tr>
<tr>
<td>CREATE ROLE</td>
<td>创建一个新角色（用户或组）</td>
</tr>
<tr>
<td>CREATE RULE</td>
<td>创建一个新规则</td>
</tr>
<tr>
<td>CREATE USER</td>
<td>创建一个新用户（角色）</td>
</tr>
<tr>
<td>CREATE SCHEMA</td>
<td>创建一个新的架构（命名空间）</td>
</tr>
<tr>
<td>CREATE SEQUENCE</td>
<td>创建一个新的序列生成器</td>
</tr>
<tr>
<td>CREATE TABLE</td>
<td>创建一个新表</td>
</tr>
<tr>
<td>CREATE TABLE AS</td>
<td>创建一个新表</td>
</tr>
<tr>
<td>CREATE TRIGGER</td>
<td>创建一个新触发器</td>
</tr>
<tr>
<td>CREATE TYPE</td>
<td>建立新类型</td>
</tr>
<tr>
<td>CREATE VIEW</td>
<td>创建一个新的视图</td>
</tr>
<tr>
<td>DEALLOCATE</td>
<td>取消分配准备好的语句</td>
</tr>
<tr>
<td>DELETE</td>
<td>从表中删除行</td>
</tr>
<tr>
<td>DO</td>
<td>执行一个匿名代码块</td>
</tr>
<tr>
<td>DROP AGGREGATE</td>
<td>删除汇总</td>
</tr>
<tr>
<td>DROP CAST</td>
<td>删除类型转换</td>
</tr>
<tr>
<td>DROP DATABASE</td>
<td>从系统中删除数据库</td>
</tr>
<tr>
<td>DROP DOMAIN</td>
<td>删除网域</td>
</tr>
<tr>
<td>DROP EXTENSION</td>
<td>删除扩展</td>
</tr>
<tr>
<td>DROP FUNCTION</td>
<td>删除功能</td>
</tr>
<tr>
<td>DROP GROUP</td>
<td>删除组（角色）</td>
</tr>
<tr>
<td>DROP OPERATOR</td>
<td>删除运算符</td>
</tr>
<tr>
<td>DROP OPERATOR CLASS</td>
<td>删除操作员类别</td>
</tr>
<tr>
<td>DROP OWNED</td>
<td>删除角色拥有的对象</td>
</tr>
<tr>
<td>DROP POLICY</td>
<td>删除行级安全策略</td>
</tr>
<tr>
<td>DROP PROCEDURE</td>
<td>删除程序</td>
</tr>
<tr>
<td>DROP ROLE</td>
<td>删除角色（用户或组）</td>
</tr>
<tr>
<td>DROP RULE</td>
<td>删除规则</td>
</tr>
<tr>
<td>DROP SEQUENCE</td>
<td>删除序列发生器</td>
</tr>
<tr>
<td>DROP TABLE</td>
<td>从数据库中删除表</td>
</tr>
<tr>
<td>DROP TRIGGER</td>
<td>删除触发器</td>
</tr>
<tr>
<td>DROP TYPE</td>
<td>删除用户定义的类型</td>
</tr>
<tr>
<td>DROP USER</td>
<td>删除用户（角色）</td>
</tr>
<tr>
<td>END</td>
<td>提交事务</td>
</tr>
<tr>
<td>EXECUTE</td>
<td>执行准备好的语句</td>
</tr>
<tr>
<td>EXPLAIN</td>
<td>显示语句的执行计划</td>
</tr>
<tr>
<td>INSERT</td>
<td>在表格中插入行</td>
</tr>
<tr>
<td>LOCK</td>
<td>锁定</td>
</tr>
<tr>
<td>PREPARE</td>
<td>准备一份声明</td>
</tr>
<tr>
<td>REASSIGN OWNED</td>
<td>重新分配拥有的对象</td>
</tr>
<tr>
<td>RESET</td>
<td>将参数重置为出厂设置</td>
</tr>
<tr>
<td>REVOKE</td>
<td>删除访问权限</td>
</tr>
<tr>
<td>ROLLBACK</td>
<td>回滚事务</td>
</tr>
<tr>
<td>SELECT</td>
<td>从表中选择行</td>
</tr>
<tr>
<td>SET</td>
<td>设置系统，会话或事务参数</td>
</tr>
<tr>
<td>SET CONSTRAINTS</td>
<td>设置当前交易的约束</td>
</tr>
<tr>
<td>SET ROLE</td>
<td>设定角色</td>
</tr>
<tr>
<td>SET SESSION AUTHORIZATION</td>
<td>设置会话授权</td>
</tr>
<tr>
<td>SET TRANSACTION</td>
<td>设置事务行为</td>
</tr>
<tr>
<td>SHOW</td>
<td>显示系统，会话或事务参数的值</td>
</tr>
<tr>
<td>SHOW TRANSACTION</td>
<td>显示交易的属性</td>
</tr>
<tr>
<td>TRUNCATE</td>
<td>清除表格中的所有行</td>
</tr>
<tr>
<td>UPDATE</td>
<td>更新表中的行</td>
</tr>
</tbody>
</table>

<h2 id="数据定义语言ddl">数据定义语言（DDL） <a href="#%e6%95%b0%e6%8d%ae%e5%ae%9a%e4%b9%89%e8%af%ad%e8%a8%80ddl" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>DDL语句通过CREATE、ALTER和DROP命令来定义数据库中的结构、更改定义以及删除定义。







<table class="table table-striped">
<thead>
<tr>
<th>声明</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ALTER DATABASE</td>
<td>更改数据库定义</td>
</tr>
<tr>
<td>ALTER SEQUENCE</td>
<td>更改序列发生器的定义</td>
</tr>
<tr>
<td>ALTER TABLE</td>
<td>更改表定义</td>
</tr>
<tr>
<td>CREATE AGGREGATE</td>
<td>创建一个新的聚集函数</td>
</tr>
<tr>
<td>CREATE CAST</td>
<td>创建新的类型转换</td>
</tr>
<tr>
<td>CREATE DATABASE</td>
<td>创建一个新的数据库</td>
</tr>
<tr>
<td>CREATE EXTENSION</td>
<td>加载扩展</td>
</tr>
<tr>
<td>CREATE FUNCTION</td>
<td>创建一个新功能</td>
</tr>
<tr>
<td>CREATE INDEX</td>
<td>创建一个新索引</td>
</tr>
<tr>
<td>CREATE OPERATOR</td>
<td>创建一个新的运算符</td>
</tr>
<tr>
<td>CREATE OPERATOR CLASS</td>
<td>创建一个新的运算符类</td>
</tr>
<tr>
<td>CREATE PROCEDURE</td>
<td>创建一个新程序</td>
</tr>
<tr>
<td>CREATE RULE</td>
<td>创建一条新规则</td>
</tr>
<tr>
<td>CREATE SCHEMA</td>
<td>创建一个新的架构（命名空间）</td>
</tr>
<tr>
<td>CREATE SEQUENCE</td>
<td>创建一个新的序列生成器</td>
</tr>
<tr>
<td>CREATE TABLE</td>
<td>创建一个新表</td>
</tr>
<tr>
<td>CREATE TABLE AS</td>
<td>创建一个新表</td>
</tr>
<tr>
<td>CREATE TRIGGER</td>
<td>创建一个新触发器</td>
</tr>
<tr>
<td>CREATE TYPE</td>
<td>创建一种新的类型</td>
</tr>
<tr>
<td>CREATE VIEW</td>
<td>创建一个新的视图</td>
</tr>
<tr>
<td>DROP AGGREGATE</td>
<td>删除汇总</td>
</tr>
<tr>
<td>DROP CAST</td>
<td>删除类型转换</td>
</tr>
<tr>
<td>DROP DATABASE</td>
<td>从系统中删除数据库</td>
</tr>
<tr>
<td>DROP EXTENSION</td>
<td>删除扩展</td>
</tr>
<tr>
<td>DROP FUNCTION</td>
<td>删除功能</td>
</tr>
<tr>
<td>DROP OPERATOR</td>
<td>删除运算符</td>
</tr>
<tr>
<td>DROP OPERATOR CLASS</td>
<td>删除运算符类</td>
</tr>
<tr>
<td>DROP PROCEDURE</td>
<td>删除一个过程</td>
</tr>
<tr>
<td>DROP RULE</td>
<td>删除程序</td>
</tr>
<tr>
<td>DROP SEQUENCE</td>
<td>删除序列发​​生器</td>
</tr>
<tr>
<td>DROP TABLE</td>
<td>从数据库中删除表</td>
</tr>
<tr>
<td>DROP TYPE</td>
<td>删除用户定义的类型</td>
</tr>
<tr>
<td>DROP TRIGGER</td>
<td>删除触发器</td>
</tr>
<tr>
<td>TRUNCATE</td>
<td>清空一个表或者一组表</td>
</tr>
</tbody>
</table>
</p>
<h2 id="数据操作语言dml">数据操作语言（DML） <a href="#%e6%95%b0%e6%8d%ae%e6%93%8d%e4%bd%9c%e8%af%ad%e8%a8%80dml" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>DML语句修改数据库的内容。







<table class="table table-striped">
<thead>
<tr>
<th>声明</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>DELETE</td>
<td>从表中删除行</td>
</tr>
<tr>
<td>INSERT</td>
<td>向表插入行</td>
</tr>
<tr>
<td>SELECT</td>
<td>从表中选择行</td>
</tr>
<tr>
<td>UPDATE</td>
<td>更新表中的行</td>
</tr>
</tbody>
</table>
</p>
<h2 id="数据控制语言dcl">数据控制语言（DCL） <a href="#%e6%95%b0%e6%8d%ae%e6%8e%a7%e5%88%b6%e8%af%ad%e8%a8%80dcl" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>DCL语句可以保护并防止数据库损坏。







<table class="table table-striped">
<thead>
<tr>
<th>声明</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ALTER  DEFAULT PRIVILEGES</td>
<td>定义默认访问权限</td>
</tr>
<tr>
<td>ALTER  GROUP</td>
<td>变更群组</td>
</tr>
<tr>
<td>ALTER  POLICY</td>
<td>更改行级安全策略</td>
</tr>
<tr>
<td>ALTER  ROLE</td>
<td>更改角色（用户或组）</td>
</tr>
<tr>
<td>ALTER  USER</td>
<td>更改用户</td>
</tr>
<tr>
<td>CREATE  GROUP</td>
<td>创建一个新组（角色）</td>
</tr>
<tr>
<td>CREATE  POLICY</td>
<td>创建一个新的行级安全策略</td>
</tr>
<tr>
<td>CREATE  ROLE</td>
<td>创建一个新角色（用户或组）</td>
</tr>
<tr>
<td>CREATE  USER</td>
<td>创建一个新用户（角色）</td>
</tr>
<tr>
<td>DROP  GROUP</td>
<td>移除群组</td>
</tr>
<tr>
<td>DROP  POLICY</td>
<td>删除行级安全策略</td>
</tr>
<tr>
<td>DROP  ROLE</td>
<td>删除角色（用户或组）</td>
</tr>
<tr>
<td>DROP  OWNED</td>
<td>删除拥有的对象</td>
</tr>
<tr>
<td>DROP  USER</td>
<td>删除用户</td>
</tr>
<tr>
<td>GRANT</td>
<td>授予权限</td>
</tr>
<tr>
<td>REASSIGN  OWNED</td>
<td>重新分配拥有对象</td>
</tr>
<tr>
<td>REVOKE</td>
<td>撤销权限</td>
</tr>
<tr>
<td>SET  ROLE</td>
<td>设定角色</td>
</tr>
<tr>
<td>SET  SESSION AUTHORIZATION</td>
<td>设置会话授权</td>
</tr>
</tbody>
</table>
</p>
<h2 id="事务控制语言tcl">事务控制语言（TCL） <a href="#%e4%ba%8b%e5%8a%a1%e6%8e%a7%e5%88%b6%e8%af%ad%e8%a8%80tcl" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p>TCL语句管理数据库上的事务。







<table class="table table-striped">
<thead>
<tr>
<th>声明</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ABORT</td>
<td>回滚事务</td>
</tr>
<tr>
<td>BEGIN</td>
<td>开始事务</td>
</tr>
<tr>
<td>COMMIT</td>
<td>提交事务</td>
</tr>
<tr>
<td>END</td>
<td>提交事务</td>
</tr>
<tr>
<td>ROLLBACK</td>
<td>回滚事务</td>
</tr>
<tr>
<td>SET  CONSTRAINTS</td>
<td>设置当前事务的约束</td>
</tr>
<tr>
<td>SET  TRANSACTION</td>
<td>设置事务行为</td>
</tr>
<tr>
<td>SHOW  TRANSACTION</td>
<td>显示事务的属性</td>
</tr>
</tbody>
</table>
</p>
<h2 id="会话和系统控制">会话和系统控制 <a href="#%e4%bc%9a%e8%af%9d%e5%92%8c%e7%b3%bb%e7%bb%9f%e6%8e%a7%e5%88%b6" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2>






<table class="table table-striped">
<thead>
<tr>
<th>声明</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>RESET</td>
<td>将参数重置为出厂设置</td>
</tr>
<tr>
<td>SET</td>
<td>设置系统，会话或事务参数</td>
</tr>
<tr>
<td>SHOW</td>
<td>显示系统，会话或事务参数的值</td>
</tr>
</tbody>
</table>

<h2 id="性能控制">性能控制 <a href="#%e6%80%a7%e8%83%bd%e6%8e%a7%e5%88%b6" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2>






<table class="table table-striped">
<thead>
<tr>
<th>声明</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>DEALLOCATE</td>
<td>取消分配准备好的语句</td>
</tr>
<tr>
<td>EXECUTE</td>
<td>执行准备好的语句</td>
</tr>
<tr>
<td>EXPLAIN</td>
<td>解释陈述的执行计划</td>
</tr>
<tr>
<td>PREPARE</td>
<td>准备一份声明</td>
</tr>
</tbody>
</table>

<h2 id="其他声明">其他声明 <a href="#%e5%85%b6%e4%bb%96%e5%a3%b0%e6%98%8e" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2>






<table class="table table-striped">
<thead>
<tr>
<th>声明</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>COPY</td>
<td>在表和文件之间复制数据</td>
</tr>
<tr>
<td>DO</td>
<td>执行一个匿名代码块</td>
</tr>
</tbody>
</table>

<h2 id="abort">ABORT <a href="#abort" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用ABORT语句回滚当前事务，并丢弃该事务的所有更新。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="7e5689b" class="language- ">
  <code>abort ::= ABORT [ TRANSACTION |  WORK ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>ABORT [ TRANSACTION | WORK ] WORK 可选。</p>
<p>TRANSACTION 可选，目前 SERIALIZABLE隔离级别暂不支持。</p>
<p><strong>例子</strong></p>
<p>创建一个名为sample的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5b377f1" class="language-sql ">
  <code>CREATE TABLE sample(k1 int,  k2 int, v1 int, v2 text, PRIMARY KEY (k1, k2));  </code>
  </pre>
  </div>
<p>在一个终端上创建一个事务并插入一些记录。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="4394843" class="language-sql ">
  <code>BEGIN TRANSACTION; 
SET TRANSACTION ISOLATION LEVEL  REPEATABLE READ;  
INSERT INTO sample(k1, k2, v1, v2) VALUES (1, 2.0, 3,  &#39;a&#39;), (1, 3.0, 4, &#39;b&#39;);  </code>
  </pre>
  </div>
<p>在第二个终端上创建一个事务并插入一些记录。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d5ad21d" class="language-sql ">
  <code>BEGIN TRANSACTION;
SET TRANSACTION ISOLATION LEVEL  REPEATABLE READ; 
INSERT INTO sample(k1, k2, v1, v2) VALUES (2, 2.0, 3,  &#39;a&#39;), (2, 3.0, 4, &#39;b&#39;);  </code>
  </pre>
  </div>
<p>在第一个终端上查看结果。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1b70d6b" class="language- ">
  <code>SELECT * FROM sample; -- run in first shell

k1 | k2 | v1 |  v2

----&#43;----&#43;----&#43;----

1 | 2 |   3 | a

1 | 3 |   4 | b

(2 rows)  </code>
  </pre>
  </div>
<p>第二个终端上查看结果。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="3205e09" class="language- ">
  <code>  SELECT * FROM sample; -- run in second shell

k1 | k2 | v1 |  v2

----&#43;----&#43;----&#43;----

2 | 2 |   3 | a

2 | 3 |   4 | b

(2 rows)  </code>
  </pre>
  </div>
<p>在第二个终端上提交事务。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c3716de" class="language- ">
  <code>COMMIT TRANSACTION; -- run in first shell.  </code>
  </pre>
  </div>
<p>在第二个终端上终止事务。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f886857" class="language- ">
  <code>ABORT TRANSACTION; -- run second shell.  </code>
  </pre>
  </div>
<p>查看表中的记录。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f9010a2" class="language- ">
  <code>SELECT * FROM sample; -- run in first shell.

k1 | k2 | v1 |  v2

----&#43;----&#43;----&#43;----

1 | 2 |   3 | a

1 | 3 |   4 | b

(2 rows)</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d79101e" class="language- ">
  <code>SELECT * FROM sample; -- run in second shell.

k1 | k2 | v1 |  v2

----&#43;----&#43;----&#43;----

1 | 2 |   3 | a

1 | 3 |   4 | b

(2 rows)  </code>
  </pre>
  </div>
<h2 id="alter-database">ALTER DATABASE <a href="#alter-database" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该ALTER DATABASE语句重新定义数据库的属性。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ff0df2d" class="language- ">
  <code> alter_database ::= ALTER DATABASE name
                     [ [ WITH ] alter_database_option [ ... ]
                       | RENAME TO name
                       | OWNER TO { new_owner
 	                              |  CURRENT_USER
 	                              |  SESSION_USER }
                        SET TABLESPACE new_tablespace
                       | SET configuration_parameter { TO | = }
                          { value | DEFAULT }
                       | SET configuration_parameter FROM CURRENT
                       | RESET configuration_parameter
                       | RESET ALL ]
 		
alter_database_option ::= ALLOW_CONNECTIONS allowconn
                             | CONNECTION LIMIT  connlimit
                             | IS_TEMPLATE  istemplate     </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>name待修改的数据库名</p>
<p>tablespace_name 指定与食宿句酷关联的新表空间</p>
<p>ALLOW_CONNECTIONS 指定false以禁止与此数据库的连接。默认值为true，允许任何具有CREATEDB权限的用户克隆此数据库。</p>
<p>CONNECTION_LIMIT 指定可以与此数据库建立多少个并发连接。默认值-1允许无限的并发连接。</p>
<p>IS_TEMPLATE 设置为true代表任何具有CREATEDB权限的用户都可以克隆此数据库。指定false时仅超级用户或数据库所有者可以克隆它。</p>
<h2 id="alter-default-privileges">ALTER DEFAULT PRIVILEGES <a href="#alter-default-privileges" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该ALTER DEFAULT PRIVILEGES语句定义默认访问权限。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ccdf5af" class="language- ">
  <code>alter_default_priv ::= ALTER DEFAULT PRIVILEGES
                           [ FOR { ROLE | USER } role_name [ , ... ] ]
                           [ IN SCHEMA schema_name [ , ... ] ]
                           abbr_grant_or_revoke
														
abbr_grant_or_revoke ::= a_grant_table
                              | a_grant_seq
                              | a_grant_func
                              | a_grant_type
                              | a_grant_schema
                              | a_revoke_table
                              | a_revoke_seq
                              | a_revoke_func
                              | a_revoke_type
                              | a_revoke_schema
													
a_grant_table ::= GRANT { grant_table_priv [ , ... ]
                            | ALL [ PRIVILEGES  ] } ON TABLES TO
                    grant_role_spec [ , ... ] [ WITH GRANT  OPTION ]
									
a_grant_seq ::= GRANT { grant_seq_priv [ , ... ]
                          | ALL [ PRIVILEGES ] } ON SEQUENCES TO
                  grant_role_spec [ , ... ] [ WITH GRANT OPTION ]
												
a_grant_func ::= GRANT { EXECUTE | ALL [ PRIVILEGES ] }  ON
                   { FUNCTIONS | ROUTINES } TO grant_role_spec [ , ... ]
                   [ WITH GRANT OPTION ]
										
a_grant_type ::= GRANT { USAGE | ALL [ PRIVILEGES ] }  ON TYPES TO
                   grant_role_spec [ , ... ] [ WITH GRANT OPTION ]
										
a_grant_schema ::= GRANT { USAGE | CREATE | ALL [  PRIVILEGES ] } ON
                     SCHEMAS TO grant_role_spec [ , ... ]
                     [ WITH GRANT OPTION ]
										
a_revoke_table ::= REVOKE [ GRANT OPTION FOR ]
                      { grant_table_priv [ , ... ] | ALL [ PRIVILEGES ] }
                      ON TABLES FROM grant_role_spec [ , ... ]
                      [ CASCADE | RESTRICT ]
											
a_revoke_seq ::= REVOKE [ GRANT OPTION FOR ]
                    { grant_seq_priv [ , ... ] | ALL  [ PRIVILEGES ] } ON
                    SEQUENCES FROM grant_role_spec [ , ... ]
                    [ CASCADE | RESTRICT ]
									
a_revoke_func ::= REVOKE [ GRANT OPTION FOR ]
                    { EXECUTE | ALL [ PRIVILEGES ] } ON
                    { FUNCTIONS | ROUTINES } FROM grant_role_spec
                    [ , ... ] [ CASCADE | RESTRICT ]
										
a_revoke_type ::= REVOKE [ GRANT OPTION FOR ]
                    { USAGE | ALL [ PRIVILEGES ] } ON TYPES FROM
                    grant_role_spec [ , ... ] [ CASCADE |  RESTRICT ]
										
a_revoke_schema ::= REVOKE [ GRANT OPTION FOR ]
                    { USAGE | CREATE | ALL [ PRIVILEGES ] } ON SCHEMAS
                    FROM grant_role_spec [ , ... ]
                    [ CASCADE | RESTRICT ]
											
grant_table_priv ::= SELECT
                       | INSERT
                       | UPDATE
                       | DELETE
                       | TRUNCATE
                       | REFERENCES
                       | TRIGGER
												
grant_seq_priv ::= USAGE | SELECT | UPDATE

grant_role_spec ::= [ GROUP ] role_name
                       | PUBLIC
                       | CURRENT_USER
                       | SESSION_USER  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>ALTER DEFAULT PRIVILEGES定义将来创建的对象的特权。它不会影响已经创建的对象。 用户只能更改由其或其成员所创建的对象的默认特权。</p>
<p><strong>例子</strong></p>
<p>授权所有用户使用SELECT访问marketing schema中所有表的权限</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f404567" class="language-sql ">
  <code>  ALTER DEFAULT PRIVILEGES IN  SCHEMA marketing GRANT SELECT ON TABLES TO PUBLIC;  </code>
  </pre>
  </div>
<p>取消用户john使用任意表时，使用INSERT语句的权限</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="4714fef" class="language-sql ">
  <code>  ALTER DEFAULT PRIVILEGES  REVOKE INSERT ON TABLES FROM john; </code>
  </pre>
  </div>
<h2 id="alter-domain">ALTER DOMAIN <a href="#alter-domain" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该ALTER DOMAIN语句更改现有域的定义。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d9a5183" class="language- ">
  <code>alter_domain_default ::= ALTER DOMAIN name
                          { SET DEFAULT expression | DROP DEFAULT }													

alter_domain_rename ::= ALTER DOMAIN name RENAME TO  name  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>SET DEFAULT | DROP DEFAULT 设置或删除域的默认值。</p>
<p>RENAME 更改域名。</p>
<p>name 指定域的名称。如果DOMAIN name不存在或DOMAIN new_name已经存在，则会提示错误。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e7ce4e3" class="language-sql ">
  <code>CREATE DOMAIN idx DEFAULT 5 CHECK (VALUE &gt; 0);

ALTER DOMAIN idx DROP DEFAULT;

ALTER DOMAIN idx RENAME TO idx_new;

DROP DOMAIN idx_new;  </code>
  </pre>
  </div>
<h2 id="alter-group">ALTER GROUP <a href="#alter-group" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该ALTER GROUP语句更改组（角色）的属性。添加它是为了与Postgres兼容。不鼓励使用。ALTER ROLE是更改角色属性的首选方法。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9a32bc5" class="language- ">
  <code>alter_group ::= ALTER GROUP role_specification { ADD |  DROP } USER
                  role_name [ , ... ]
										
role_specification ::= role_name | CURRENT_USER |  SESSION_USER

alter_group_rename ::= ALTER GROUP role_name RENAME TO  new_role_name  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>ALTER GROUP可用于在组中添加或删除角色。请使用GRANT或REVOKE代替。也可以用来重命名角色。</p>
<h2 id="alter-policy">ALTER POLICY <a href="#alter-policy" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该ALTER POLICY语句可以更改现有行级安全策略的定义。它可用于更改策略适用的角色以及策略的USING和CHECK表达式。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e289a5b" class="language- ">
  <code>alter_policy ::= ALTER POLICY name ON table_name
                    [ TO { role_name
                            | PUBLIC
                            | CURRENT_USER
                            | SESSION_USER } [ , ... ] ]
                    [ USING ( using_expression ) ]
                    [ WITH CHECK ( check_expression ) ]
															
alter_policy_rename ::= ALTER POLICY name ON table_name  RENAME TO
                          new_name  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>name 是要更新的策略的名称。</p>
<p>table_name 是应用策略的表的名称。</p>
<p>new_name 测略的新名称</p>
<p>role_name 该策略使用的橘色，如使用PUBLIC则策略适用于所有角色</p>
<p>using_expression 是SQL条件表达式，满足条件的行将在SELECT中可见，在UPDATE和DELETE修改操作中有效。</p>
<p>check_expression 是SQL条件表达式，仅被用在INSERT和UPDATE查询中。条件为true的内容允许INSERT和UPDATE。与using_expression不同，它使用来检查新内容的。</p>
<p><strong>例子</strong></p>
<p>重命名策略。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d1bc1e6" class="language-sql ">
  <code>  ALTER POLICY p1 ON table_foo RENAME TO p2;  </code>
  </pre>
  </div>
<p>将策略应用于所有角色。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8273b0f" class="language-sql ">
  <code> ALTER POLICY p1 ON table_foo TO PUBLIC; </code>
  </pre>
  </div>
<h2 id="alter-role">ALTER ROLE <a href="#alter-role" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用ALTER ROLE语句更改角色（用户或组）的属性。 超级用户可以更改任何角色的属性。具有CREATEROLE权限的角色可以更改任何非超级用户角色的属性。其他角色只能更改自己的密码。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="88d0885" class="language- ">
  <code>alter_role ::= ALTER ROLE role_specification
                  [ [ WITH ] alter_role_option [  , ... ] ]
									
alter_role_option ::= SUPERUSER
                         | NOSUPERUSER
                         | CREATEDB
                         | NOCREATEDB
                         | CREATEROLE
                         | NOCREATEROLE
                         | INHERIT
                         | NOINHERIT
                         | LOGIN
                         | NOLOGIN
                         | CONNECTION LIMIT connlimit
                         | [ ENCRYPTED ]  PASSWORD &#39; password &#39;
                         | PASSWORD NULL
                         | VALID UNTIL &#39; timestamp &#39;
										
role_specification ::= role_name | CURRENT_USER |  SESSION_USER

alter_role_rename ::= ALTER ROLE role_name RENAME TO  new_role_name

alter_role_config ::= ALTER ROLE { role_specification |  ALL }
                         [ IN DATABASE database_name ] config_setting
												
config_setting ::= SET config_param { TO | = }
                         { config_value | DEFAULT }
                         | SET config_param FROM CURRENT
                         | RESET config_param
                         | RESET ALL  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>role_specification 指定要更改其属性的角色的名称或当前用户或当前会话用户。</p>
<p>SUPERUSER，NOSUPERUSER 确定角色是否是“超级用户”。超级用户可以覆盖所有访问限制，应谨慎使用。只有具有SUPERUSER权限的角色才能创建其他SUPERUSER角色。</p>
<p>CREATEDB，NOCREATEDB 确定角色是否可以创建数据库。</p>
<p>CREATEROLE，NOCREATEROLE 确定角色是否可以创建其他角色。</p>
<p>INHERIT，NOINHERIT 确定角色是否继承其所属角色的特权。如果没有INHERIT，则另一个角色的成员资格仅授予SET ROLE权限给该另一个角色。其他角色的权限只有在这样做之后才可用。</p>
<p>LOGIN，NOLOGIN 确定是否允许新角色登录。客户端连接期间只能使用具有登录权限的角色。</p>
<p>CONNECTION LIMIT 指定角色可以建立的并发连接数。这仅适用于可以登录的角色。</p>
<p>[ENCRYPTED] PASSWORD 设置角色的密码。这仅适用于可以登录的角色。如果未指定密码，则密码将设置为null，并且该用户的密码身份验证将始终失败。请注意，密码始终以加密方式存储在系统目录中，并且仅出于与Postgres兼容而提供可选关键字ENCRYPTED。</p>
<p>VALID UNTIL 设置一个日期和时间，之后该角色的密码将不再有效。</p>
<p>config_param, config_value 是名称和配置参数被设置值</p>
<p>ALTER ROLE role_name RENAME TO 可用于更改角色名称。请注意，当前会话角色无法重命名。因为MD5加密的密码使用角色名称作为加密盐，所以如果密码是MD5加密的，重命名角色将清除其密码。</p>
<p>ALTER ROLE SET | RESET config_param 用于更改所有数据库的配置变量的角色会话默认值，或者用于更改指定数据库中的会话的IN DATABASE子句时的默认值。如果指定了ALL而不是角色名称，则将更改所有角色的设置。</p>
<p><strong>例子</strong></p>
<p>更改角色密码。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c0dfd6d" class="language-sql ">
  <code>ALTER ROLE John WITH  PASSWORD &#39;new_password&#39;; </code>
  </pre>
  </div>
<p>重命名角色。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a8b01e8" class="language-sql ">
  <code>ALTER ROLE John RENAME TO  Jane;  </code>
  </pre>
  </div>
<p>更改角色的default_transaction_isolation会话参数。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="22a7509" class="language-sql ">
  <code>ALTER ROLE Jane SET  default_transaction_isolation=&#39;serializable&#39;;  </code>
  </pre>
  </div>
<h2 id="alter-sequence">ALTER SEQUENCE <a href="#alter-sequence" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该ALTER SEQUENCE语句可以更改当前模式中现有序列的定义。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9c82c92" class="language- ">
  <code>alter_sequence ::= ALTER SEQUENCE [ IF EXISTS ] name
                      alter_sequence_options
											
name ::= &#39;&lt;Text Literal&gt;&#39;

alter_sequence_options ::= [ AS seq_data_type ]
                                 [ INCREMENT [ BY ]  increment ]
                                 [ MINVALUE  minvalue | NO MINVALUE ]
                                 [ MAXVALUE  maxvalue | NO MAXVALUE ]
                                 [ START [ WITH ]  start ]
                                 [ RESTART [ [ WITH  ] restart ] ]
                                 [ CACHE cache ]
                                 [ OWNED BY  table_name.table_column | NONE ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>ALTER SEQUENCE sequence_name [ IF EXISTS ] 指定序列的名称（sequence_name）。如果当前架构中不存在具有该名称的序列，并且IF EXISTS未指定该序列，则会引发错误。</p>
<p>AS datatype 更改序列的数据类型。如果先前的值超出了新类型所允许的范围，则会自动更改序列的最小值和最大值。有效类型smallint，integer和bigint。</p>
<p>INCREMENT BY increment 指定序列中连续值之间的差。默认值为1。</p>
<p>MINVALUE minvalue | NO MINVALUE 指定序列中允许的最小值。如果达到此值（以负增量递增的顺序），nextval()将返回错误。如果NO MINVALUE指定，则使用默认值。默认值为1。 MAXVALUE maxvalue | NO MAXVALUE 指定序列中允许的最大值。如果达到此值，nextval()将返回错误。如果NO MAXVALUE指定，则使用默认值。默认值为263 - 1。</p>
<p>START WITH start 指定序列中的第一个值。start不能少于minvalue。默认值为1。</p>
<p>RESTART [ [ WITH ] restart ] ] 更改序列的当前值。如果未指定任何值，则当前值将设置START [ WITH ]为创建或更改序列时指定的最后一个值。</p>
<p>CACHE cache 指定序列中要在客户端中缓存的数字。默认值为1。 OWNED BY table_name.table_column | NONE 它将序列的所有权授予指定的列（如果有）。这意味着如果删除了列（或它所属的表），则序列将被自动删除。如果NONE指定，则将删除以前的所有所有权。</p>
<h2 id="alter-table">ALTER TABLE <a href="#alter-table" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用ALTER TABLE语句更改现有表的定义。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1d58adb" class="language- ">
  <code>alter_table ::= ALTER TABLE [ ONLY ] name [ * ]  alter_table_action
                   [  , ... ]
											
alter_table_action ::= ADD [ COLUMN ] column_name  data_type
                           [ alter_column_constraint [ ... ] ]
                           | RENAME TO table_name
                           | DROP [ COLUMN ] column_name
                             [ RESTRICT | CASCADE ]
                           | ADD  alter_table_constraint
                           | DROP CONSTRAINT constraint_name
                             [ RESTRICT | CASCADE ]
                           | RENAME [ COLUMN ] column_name TO column_name
                           | DISABLE ROW LEVEL SECURITY
                           | ENABLE ROW LEVEL SECURITY
                           | FORCE ROW LEVEL SECURITY
                           | NO FORCE ROW LEVEL SECURITY
														
alter_table_constraint ::= [ CONSTRAINT constraint_name  ]
                                 { CHECK (  expression )
                                   | UNIQUE (  column_names )
                                     index_parameters
                                   | FOREIGN KEY (  column_names )
                                     references_clause  }
                                 [ DEFERRABLE | NOT  DEFERRABLE ]
                                 [ INITIALLY  DEFERRED
                                   | INITIALLY  IMMEDIATE ]
																	
alter_column_constraint ::= [ CONSTRAINT  constraint_name ]
                                 { NOT NULL
                                   | NULL
                                   | CHECK (  expression )
                                   | DEFAULT  expression
                                   | UNIQUE  index_parameters
                                   |  references_clause }
                                [ DEFERRABLE |  NOT DEFERRABLE ]
                                [ INITIALLY  DEFERRED
                                   | INITIALLY  IMMEDIATE ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>ALTER TABLE [ ONLY ] name [ * ] alter_table_action [ , &hellip; ] 更改指定的表和依赖项。</p>
<ul>
<li>ONLY 将更改限制为指定的表</li>
</ul>
<p>ADD [ COLUMN ] column_name data_type constraint 添加具有指定数据类型和约束的指定列。</p>
<p>RENAME TO table_name 将表重命名为指定的表名。</p>
<p>DROP [ COLUMN ] column_name [ RESTRICT | CASCADE ] 从表中删除命名列。</p>
<ul>
<li>RESTRICT 仅删除指定的</li>
</ul>
<p>ADD alter_table_constraint 添加具有指定数据类型和约束的指定列。</p>
<p>DROP CONSTRAINT constraint_name [ RESTRICT | CASCADE ] 从表中删除命名列。</p>
<ul>
<li>RESTRICT —仅删除指定的约束。</li>
<li>CASCADE —删除指定的约束和所有依赖关系。</li>
</ul>
<p>**RENAME [ COLUMN ] column_name TO column_name ** 将列重命名为指定名称。</p>
<p>ENABLE / DISABLE ROW LEVEL SECURITY 这将启用或禁用表的行级安全性。如果启用并且该表不存在任何策略，则将应用默认拒绝策略。如果禁用，则将不应用该表的现有策略，并将其忽略。有关如何创建行级安全策略的详细信息，请参见创建策略。</p>
<p>FORCE / NO FORCE ROW LEVEL SECURITY 当用户是表所有者时，这将控制表的行安全策略的应用。如果启用，则当用户是表所有者时，将应用行级安全策略。如果禁用（默认设置），则当用户是表所有者时，将不应用行级安全性。有关如何创建行级安全策略的详细信息，请参见创建策略。</p>
<p>CONSTRAINT constraint_name 指定约束的名称。</p>
<p>Foreign key FOREIGN KEY和REFERENCES指定外键。它用于强制数据的参照完整性。 Unique 这将强制UNIQUE约束在表中指定的列集在表中是唯一的，也就是说，对于约束中指定的列集，没有两行可以具有相同的值 Check 这用于强制指定表中的数据满足该CHECK子句中指定的要求。 Default 用于指定列的默认值。如果INSERT语句未为该列指定值，则使用默认值。如果没有为列指定默认值，则默认值为NULL。</p>
<p>Deferrable constraints 可以使用该DEFERRABLE子句推迟约束。当前，在MemFire中只能推迟外键约束。在语句中的每一行之后，将检查不可延迟的约束。在可延迟约束的情况下，约束的检查可以推迟到事务结束。 标记为 INITIALLY IMMEDIATE 的约束将在语句中的每一行之后进行检查。 标记为 INITIALLY DEFERRED 的约束将在事务结束时检查。</p>
<h2 id="alter-user">ALTER USER <a href="#alter-user" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该ALTER USER语句来更改角色。ALTER USER是 ALTER ROLE的 别名，用于更改角色。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="0ea85bd" class="language- ">
  <code>alter_user ::= ALTER USER role_specification
                  [  [ WITH ] alter_role_option [ , ... ] ]
                  
alter_role_option ::= SUPERUSER
                         | NOSUPERUSER
                         | CREATEDB
                         | NOCREATEDB
                         | CREATEROLE
                         | NOCREATEROLE
                         | INHERIT
                         | NOINHERIT
                         | LOGIN
                         | NOLOGIN
                         | CONNECTION LIMIT connlimit
                         | [ ENCRYPTED ] PASSWORD &#39;  password &#39;
                         | PASSWORD NULL
                         | VALID UNTIL &#39; timestamp &#39;
                         
role_specification ::= role_name | CURRENT_USER |  SESSION_USER

alter_user_rename ::= ALTER USER role_name RENAME TO  new_role_name

alter_user_config ::= ALTER USER { role_specification |  ALL }
                         [ IN DATABASE database_name ] config_setting
                         
config_setting ::= SET config_param { TO | = }
                       { config_value | DEFAULT }
                       | SET config_param FROM CURRENT
                       | RESET config_param
                       | RESET ALL  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>参阅ALTER_ROLE</p>
<h2 id="begin">BEGIN <a href="#begin" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该BEGIN语句以默认（或给定）隔离级别启动新事务。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8f6e32e" class="language- ">
  <code>BEGIN [ TRANSACTION | WORK ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>ABORT [ TRANSACTION | WORK ] WORK 可选</p>
<p><strong>例子</strong></p>
<p>创建名为sample的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="40c36ce" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text,  PRIMARY KEY (k1, k2));  </code>
  </pre>
  </div>
<p>启动一个事务并插入一些数据。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="b1cb4ad" class="language-sql ">
  <code>BEGIN TRANSACTION; SET TRANSACTION ISOLATION LEVEL  REPEATABLE READ;   INSERT INTO sample(k1, k2, v1, v2) VALUES (1, 2.0, 3,  &#39;a&#39;), (1, 3.0, 4, &#39;b&#39;);  </code>
  </pre>
  </div>
<p>启动第二个事务并插入一些记录。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f9372af" class="language-sql ">
  <code>BEGIN TRANSACTION; SET TRANSACTION ISOLATION LEVEL  REPEATABLE READ;   INSERT INTO sample(k1, k2, v1, v2) VALUES (2, 2.0, 3,  &#39;a&#39;), (2, 3.0, 4, &#39;b&#39;);  </code>
  </pre>
  </div>
<p>在每个事务中查看刚插入的内容。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="fdbdcdf" class="language- ">
  <code>SELECT * FROM sample; -- run in first shell
k1 | k2 | v1 |  v2
----&#43;----&#43;----&#43;----
1 | 2 |   3 | a
1 | 3 |   4 | b
(2 rows)

SELECT * FROM sample; -- run in second shell
k1 | k2 | v1 |  v2
----&#43;----&#43;----&#43;----
2 | 2 |   3 | a
2 | 3 |   4 | b
(2 rows) </code>
  </pre>
  </div>
<p>提交第一个事务</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e537dbb" class="language-sql ">
  <code>COMMIT TRANSACTION; -- run  in first shell.  </code>
  </pre>
  </div>
<p>终止第二个事务</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e593435" class="language-sql ">
  <code>ABORT TRANSACTION; -- run  second shell.  </code>
  </pre>
  </div>
<p>查看最终结果</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="bde0a91" class="language- ">
  <code>SELECT * FROM sample; -- run in first shell.
k1 | k2 | v1 |  v2
----&#43;----&#43;----&#43;----
1 | 2 |   3 | a
1 | 3 |   4 | b
(2 rows)</code>
  </pre>
  </div>
<h2 id="comment">COMMENT <a href="#comment" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用COMMENT语句设置，更新或删除数据库对象的注释。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="fdf7d54" class="language- ">
  <code>comment_on ::= COMMENT ON
                {  ACCESS METHOD object_name
                   | AGGREGATE aggregate_name ( aggregate_signature )
                   | CAST ( source_type AS target_type )
                   | COLLATION object_name
                   | COLUMN relation_name . column_name
                   | CONSTRAINT constraint_name ON table_name
                   | CONSTRAINT constraint_name ON DOMAIN domain_name
                   | CONVERSION object_name
                   | DATABASE object_name
                   | DOMAIN object_name
                   | EXTENSION object_name
                   | EVENT TRIGGER object_name
                   | FOREIGN DATA WRAPPER object_name
                   | FOREIGN TABLE object_name
                   | FUNCTION function_name [ ( function_signature ) ]
                   | INDEX object_name
                   | LARGE OBJECT large_object_oid
                   | OPERATOR operator_name ( operator_signature )
                   | OPERATOR CLASS object_name USING index_method
                   | OPERATOR FAMILY object_name USING index_method
                   | POLICY policy_name ON table_name
                   | [ PROCEDURAL ] LANGUAGE object_name
                   | PROCEDURE procedure_name
                     [ ( [ [ argmode ] [ argname ] argtype [ , ... ] ] ) ]
                   | PUBLICATION object_name
                   | ROLE object_name
                   | ROUTINE routine_name
                     [ ( [ [ argmode ] [ argname ] argtype [ , ... ] ] ) ]
                   | RULE rule_name ON table_name
                   | SCHEMA object_name
                   | SEQUENCE object_name
                   | SERVER object_name
                   | STATISTICS object_name
                   | SUBSCRIPTION object_name
                   | TABLE object_name
                   | TABLESPACE object_name
                   | TEXT SEARCH CONFIGURATION object_name
                   | TEXT SEARCH DICTIONARY object_name
                   | TEXT SEARCH PARSER object_name
                   | TEXT SEARCH TEMPLATE object_name
                   | TRANSFORM FOR type_name  LANGUAGE lang_name
                   | TRIGGER trigger_name ON table_name
                   | TYPE object_name
                   | VIEW object_name } IS { &#39;&lt;Text Literal&gt;&#39; | NULL } </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>COMMENT ON 添加或更改有关数据库对象的注释。要删除评论，请将值设置为NULL。</p>
<p><strong>例子</strong></p>
<p>添加注释。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8089be7" class="language-sql ">
  <code>COMMENT ON DATABASE postgres IS &#39;Default database&#39;;

COMMENT ON INDEX index_name IS &#39;Special index&#39;;  </code>
  </pre>
  </div>
<p>删除注释。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e419ed5" class="language-sql ">
  <code> COMMENT ON TABLE some_table IS NULL;  </code>
  </pre>
  </div>
<h2 id="commit">COMMIT <a href="#commit" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用COMMIT语句提交当前事务。事务所做的所有更改对其他人都可见，并且如果发生崩溃，则保证是持久的。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c93da03" class="language- ">
  <code>commit ::= COMMIT [ TRANSACTION  | WORK ] </code>
  </pre>
  </div>
<p><strong>语义</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="52caf2d" class="language- ">
  <code>COMMIT [ TRANSACTION | WORK  ]  </code>
  </pre>
  </div>
<p>WORK 可选</p>
<p>TRANSACTION 可选 SERIALIZABLE隔离级别暂不支持</p>
<p><strong>例子</strong></p>
<p>创建一个名为sample的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d90773e" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text, PRIMARY KEY (k1, k2)); </code>
  </pre>
  </div>
<p>在一个终端上创建一个事务并插入一些记录。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="dc26139" class="language-sql ">
  <code>BEGIN TRANSACTION; SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
INSERT INTO sample(k1, k2, v1, v2) VALUES (1, 2.0, 3,  &#39;a&#39;), (1, 3.0, 4, &#39;b&#39;);</code>
  </pre>
  </div>
<p>在第二个终端上创建一个事务并插入一些记录。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2061c7d" class="language-sql ">
  <code>BEGIN TRANSACTION; SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
INSERT INTO sample(k1, k2, v1, v2) VALUES (2, 2.0, 3,  &#39;a&#39;), (2, 3.0, 4, &#39;b&#39;);</code>
  </pre>
  </div>
<p>在第一个终端上查看结果。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8b79898" class="language- ">
  <code>SELECT * FROM sample; -- run in first shell
k1 | k2 | v1 |  v2
----&#43;----&#43;----&#43;----
1 | 2 | 3 | a
1 | 3 | 4 | b
(2 rows)</code>
  </pre>
  </div>
<p>第二个终端上查看结果。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ed0f11b" class="language- ">
  <code>SELECT * FROM sample; -- run in second shell
k1 | k2 | v1 |  v2
----&#43;----&#43;----&#43;----
2 | 2 | 3 | a
2 | 3 | 4 | b
(2 rows)  </code>
  </pre>
  </div>
<p>在第二个终端上提交事务。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ccde8d9" class="language-sql ">
  <code>COMMIT TRANSACTION; -- run in first shell.</code>
  </pre>
  </div>
<p>在第二个终端上终止事务。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a9d3551" class="language-sql ">
  <code>ABORT TRANSACTION; -- run second shell. </code>
  </pre>
  </div>
<p>查看表中的记录。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9cabdb4" class="language- ">
  <code>SELECT * FROM sample; -- run in first shell.
k1 | k2 | v1 |  v2
----&#43;----&#43;----&#43;----
1 | 2 | 3 | a
1 | 3 | 4 | b
(2 rows) </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="7c3eff8" class="language- ">
  <code>SELECT * FROM sample; -- run in second shell.
k1 | k2 | v1 |  v2
----&#43;----&#43;----&#43;----
1 | 2 | 3 | a
1 | 3 | 4 | b
(2 rows)</code>
  </pre>
  </div>
<h2 id="copy">COPY <a href="#copy" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用COPY语句在表和文件之间传输数据。COPY TO将数据从表复制到文件。COPY FROM将数据从文件复制到表。COPY输出已复制的行数。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9f53992" class="language- ">
  <code>copy_from ::= COPY table_name [ ( column_name [ , ... ]  ) ] FROM
                {  &#39;filename&#39; | PROGRAM &#39;command&#39; | STDIN }
                [ [  WITH ] ( option [ , ... ] ) ]
                
copy_to ::= COPY { table_name [ ( column_names ) ] | (  query ) } TO
                {  &#39;filename&#39; | PROGRAM &#39;command&#39; | STDOUT }
                [ [  WITH ] ( option [ , ... ] ) ]
                
copy_option ::= FORMAT format_name
                  |  OIDS [ boolean ]
                  |  FREEZE [ boolean ]
                  |  DELIMITER &#39;delimiter_character&#39;
                  |  NULL &#39;null_string&#39;
                  |  HEADER [ boolean ]
                  |  QUOTE &#39;quote_character&#39;
                  |  ESCAPE &#39;escape_character&#39;
                  |  FORCE_QUOTE { ( column_names ) | * }
                  |  FORCE_NOT_NULL ( column_names )
                  |  FORCE_NULL ( column_names )
                  |  ENCODING &#39;encoding_name&#39;</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>table_name 指定要复制的表（可以选择模式限定的表）。</p>
<p>column_name 指定要复制的列的列表。如果未指定，则将复制表的所有列。</p>
<p>query 指定SELECT，VALUES，INSERT，UPDATE，或DELETE语句，它的结果将被复制。对于INSERT，UPDATE和DELETE语句，必须提供RETURNING子句。</p>
<p>filename 指定要复制的文件的路径。输入文件名可以是绝对路径或相对路径，但输出文件名必须是绝对路径。</p>
<p><strong>例子</strong></p>
<ul>
<li>如果表不存在，则会引发错误。</li>
<li>COPY TO 只能与常规表一起使用。</li>
<li>COPY FROM 可以与表，外部表或视图一起使用。</li>
</ul>
<h2 id="create-aggregate">CREATE AGGREGATE <a href="#create-aggregate" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE AGGREGATE语句创建一个新的聚合函数。有三种创建聚合的方法。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e7eb988" class="language- ">
  <code>create_aggregate ::= create_aggregate_normal
                        | create_aggregate_order_by
                        | create_aggregate_old
                        
create_aggregate_normal ::= CREATE AGGREGATE  aggregate_name (
                                { aggregate_arg [  , ... ] | * } ) ( SFUNC
                                = sfunc , STYPE =  state_data_type
                                [ ,  aggregate_normal_option [ ... ] ] )
                                
create_aggregate_order_by ::= CREATE AGGREGATE  aggregate_name (
                                [ aggregate_arg  [ , ... ] ] ORDER BY
                                aggregate_arg [  , ... ] ) ( SFUNC =
                                sfunc , STYPE =  state_data_type
                                [ ,  aggregate_order_by_option [ ... ] ]
                                )
                                
create_aggregate_old ::= CREATE AGGREGATE  aggregate_name ( BASETYPE =
                            base_type , SFUNC = sfunc , STYPE =
                            state_data_type
                            [ , aggregate_old_option [ ... ] ] )
                            

aggregate_arg ::= [ aggregate_argmode ] [ argname ]  argtype

aggregate_normal_option ::= SSPACE = state_data_size
                               | FINALFUNC =  ffunc
                               | FINALFUNC_EXTRA
                               |  FINALFUNC_MODIFY =
                                  { READ_ONLY |  SHAREABLE | READ_WRITE }
                               | COMBINEFUNC =  combinefunc
                               | SERIALFUNC =  serialfunc
                               | DESERIALFUNC =  deserialfunc
                               | INITCOND =  initial_condition
                               | MSFUNC = msfunc
                               | MINVFUNC = minvfunc
                               | MSTYPE =  mstate_data_type
                               | MSSPACE =  mstate_data_size
                               | MFINALFUNC =  mffunc
                               |  MFINALFUNC_EXTRA
                               | MFINALFUNC_MODIFY =
                                  { READ_ONLY |  SHAREABLE | READ_WRITE }
                               | MINITCOND =  minitial_condition
                               | SORTOP =  sort_operator
                               | PARALLEL =
                                  { SAFE |  RESTRICTED | UNSAFE }
                                  
aggregate_order_by_option ::= SSPACE = state_data_size
                                 | FINALFUNC =  ffunc
                                 |  FINALFUNC_EXTRA
                                 |  FINALFUNC_MODIFY =
                                    { READ_ONLY |  SHAREABLE | READ_WRITE }
                                 | INITCOND =  initial_condition
                                 | PARALLEL =
                                    { SAFE | RESTRICTED | UNSAFE }
                                 | HYPOTHETICAL
                                 
aggregate_old_option ::= SSPACE = state_data_size
                           | FINALFUNC = ffunc
                           | FINALFUNC_EXTRA
                           | FINALFUNC_MODIFY =
                              { READ_ONLY |  SHAREABLE | READ_WRITE }
                           | COMBINEFUNC = combinefunc
                           | SERIALFUNC = serialfunc
                           | DESERIALFUNC = deserialfunc
                           | INITCOND =  initial_condition
                           | MSFUNC = msfunc
                           | MINVFUNC = minvfunc
                           | MSTYPE = mstate_data_type
                           | MSSPACE = mstate_data_size
                           | MFINALFUNC = mffunc
                           | MFINALFUNC_EXTRA
                           | MFINALFUNC_MODIFY =
                              { READ_ONLY |  SHAREABLE | READ_WRITE }
                           | MINITCOND = minitial_condition
                           | SORTOP = sort_operator  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>选项的顺序无关紧要。甚至强制性选项BASETYPE，SFUNC和STYPE 可能以任何顺序出现。</p>
<p>请参见[PostgreSQL docs] [postgresql-docs-create-aggregate]中每个选项的语义。</p>
<p><strong>例子</strong></p>
<p>普通语法示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="47594d1" class="language-sql ">
  <code>CREATE AGGREGATE sumdouble (float8) (
           STYPE = float8,
           SFUNC = float8pl,
           MSTYPE = float8,
           MSFUNC = float8pl,
           MINVFUNC = float8mi
           );
           
CREATE TABLE normal_table(
          f  float8,
          i  int
        );
        
INSERT INTO normal_table(f, i) VALUES
          (0.1, 9),
          (0.9, 1);
          
SELECT sumdouble(f), sumdouble(i) FROM normal_table;  </code>
  </pre>
  </div>
<p>带排序的语法示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="b102d5d" class="language-sql ">
  <code>CREATE AGGREGATE my_percentile_disc(float8 ORDER BY  anyelement) (
           STYPE = internal,
           SFUNC = ordered_set_transition,
           FINALFUNC = percentile_disc_final,
           FINALFUNC_EXTRA = true,
           FINALFUNC_MODIFY = read_write
        );
        
SELECT my_percentile_disc(0.1), my_percentile_disc(0.9)
           WITHIN GROUP (ORDER BY typlen)
           FROM  pg_type;  </code>
  </pre>
  </div>
<p>旧的语法示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="7a6eea3" class="language-sql ">
  <code>CREATE AGGREGATE oldcnt(
          SFUNC = int8inc,
          BASETYPE = &#39;ANY&#39;,
          STYPE = int8,
          INITCOND = &#39;0&#39;
       );
       
SELECT oldcnt(*) FROM pg_aggregate; </code>
  </pre>
  </div>
<p>零参数聚合示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5401343" class="language-sql ">
  <code>CREATE AGGREGATE newcnt(*) (
          SFUNC = int8inc,
          STYPE = int8,
          INITCOND = &#39;0&#39;,
          PARALLEL = SAFE
       );
       
SELECT newcnt(*) FROM pg_aggregate;</code>
  </pre>
  </div>
<h2 id="create-cast">CREATE CAST <a href="#create-cast" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE CAST语句创建新的数据转换。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8c752be" class="language- ">
  <code>create_cast ::= create_cast_with_function
                    |  create_cast_without_function
                    |  create_cast_with_inout
                    
create_cast_with_function ::= CREATE CAST (  cast_signature ) WITH
                                  FUNCTION function_name
                                  [ (  function_signature ) ]
                                  [ AS ASSIGNMENT  | AS IMPLICIT ]
                                  
create_cast_without_function ::= CREATE CAST (  cast_signature ) WITHOUT  FUNCTION
                                   [ AS  ASSIGNMENT | AS IMPLICIT ]
                                   
create_cast_with_inout ::= CREATE CAST ( cast_signature  ) WITH INOUT
                              [ AS ASSIGNMENT |  AS IMPLICIT ]
                              
cast_signature ::= source_type AS target_type</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-create-cast]中每个选项的语义。</p>
<p><strong>例子</strong></p>
<p>WITH FUNCTION例子。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="aef7f12" class="language-sql ">
  <code>CREATE FUNCTION sql_to_date(integer) RETURNS date AS $$
          SELECT $1::text::date
          $$  LANGUAGE SQL IMMUTABLE STRICT;
          
CREATE CAST (integer AS date) WITH FUNCTION  sql_to_date(integer) AS ASSIGNMENT;  SELECT CAST (3 AS date);</code>
  </pre>
  </div>
<p>WITHOUT FUNCTION例子。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1fcf516" class="language-sql ">
  <code>CREATE TYPE myfloat4;

CREATE FUNCTION myfloat4_in(cstring) RETURNS myfloat4
           LANGUAGE internal IMMUTABLE STRICT  PARALLEL SAFE AS &#39;float4in&#39;;
           
CREATE FUNCTION myfloat4_out(myfloat4) RETURNS cstring
           LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS &#39;float4out&#39;;
           
CREATE TYPE myfloat4 (
           INPUT = myfloat4_in,
           OUTPUT = myfloat4_out,
           LIKE  = float4
        );
        
SELECT CAST(&#39;3.14&#39;::myfloat4 AS float4);

CREATE CAST (myfloat4 AS float4) WITHOUT FUNCTION;

SELECT CAST(&#39;3.14&#39;::myfloat4 AS float4);  </code>
  </pre>
  </div>
<p>WITH INOUT例子。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1c96de1" class="language-sql ">
  <code>CREATE TYPE myint4;

CREATE FUNCTION myint4_in(cstring) RETURNS myint4
           LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS &#39;int4in&#39;;
           
CREATE FUNCTION myint4_out(myint4) RETURNS cstring
           LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS &#39;int4out&#39;;
           
CREATE TYPE myint4 (
           INPUT = myint4_in,
           OUTPUT = myint4_out,
           LIKE  = int4
        );
        
SELECT CAST(&#39;2&#39;::myint4 AS int4);

CREATE CAST (myint4 AS int4) WITH INOUT;

SELECT CAST(&#39;2&#39;::myint4 AS int4);</code>
  </pre>
  </div>
<h2 id="create-database">CREATE DATABASE <a href="#create-database" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE DATABASE语句创建一个数据库。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1e46d5f" class="language- ">
  <code>create_database ::= CREATE DATABASE name [  create_database_options ]

create_database_options ::= [ WITH ] [ OWNER [ = ]  user_name ]
                                [ TEMPLATE [ = ]  template ]
                                [ ENCODING [ = ]  encoding ]
                                [ LC_COLLATE [ =  ] lc_collate ]
                                [ LC_CTYPE [ = ]  lc_ctype ]
                                [ TABLESPACE [ = ]  tablespace_name ]
                                [  ALLOW_CONNECTIONS [ = ] allowconn ]
                                [ COLOCATED [ = ]  { &#39;true&#39; | &#39;false&#39; } ] </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>CREATE DATABASE name 指定要创建的数据库的名称。如果要创建的数据库name已经存在，则会返回错误。</p>
<p>[ WITH ] OWNER user_name 指定将拥有新数据库的用户的角色名称。如果未指定，则数据库创建者为所有者。</p>
<p>TEMPLATE template 指定用于创建新数据库的模板的名称。</p>
<p>ENCODING encoding 指定在新数据库中使用的字符集编码。</p>
<p>LC_COLLATE lc_collate 指定排序顺序 (LC_COLLATE),目前只支持C。</p>
<p>LC_CTYPE lc_ctype 指定字符分类（LC_CTYPE），目前只支持utf-8。</p>
<p>TABLESPACE tablespace_name 指定与数据库关联的新表空间。</p>
<p>ALLOW_CONNECTIONS allowconn 指定false时禁止连接数据库。默认值为true，允许连接数据库。</p>
<p>COLOCATED 指定true此数据库的所有表是否应位于同一tablet上。查看并置表架构 有关何时使用共置表的详细信息。默认值为false，数据库中的每个表都有自己的一组tablet。</p>
<p><strong>例子</strong></p>
<p>创建一个并置数据库。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="02fe183" class="language-sql ">
  <code>CREATE DATABASE company WITH  COLOCATED = true;  </code>
  </pre>
  </div>
<p>在此示例中，数据库company中的所有表都放置在同一个tablet上</p>
<h2 id="create-domain">CREATE DOMAIN <a href="#create-domain" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE DOMAIN语句来创建新的域。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="27bde18" class="language- ">
  <code>create_domain ::= CREATE DOMAIN name [ AS ] data_type
                    [ DEFAULT expression ]
                    [ [ domain_constraint [ ... ] ] ]
                    
domain_constraint ::= [ CONSTRAINT constraint_name ]
                          { NOT NULL | NULL | CHECK ( expression ) } </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>CREATE DOMAIN name 指定域的名称。如果name中已存在，则会引发错误。</p>
<p>AS data_type 指定基础数据类型。</p>
<p>DEFAULT expression 为域设置默认值。</p>
<p>CONSTRAINT constraint_name 指定约束的名称。</p>
<p>NOT NULL 不允许为空值。 NULL 允许为空值（默认）。 CHECK ( expression ) 域值必须满足的约束，返回布尔值。表达式为 为TRUE或UNKNOWN时代表成功。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="816eb10" class="language-sql ">
  <code>CREATE DOMAIN phone_number AS TEXT CHECK(VALUE ~ &#39;^\d{3}-\d{3}-\d{4}$&#39;);</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="7aa0209" class="language-sql ">
  <code>CREATE TABLE person(first_name TEXT, last_name TEXT, phone_number phone_number);  </code>
  </pre>
  </div>
<h2 id="create-extension">CREATE EXTENSION <a href="#create-extension" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE EXTENSION语句将扩展加载到数据库中。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9bb56c0" class="language- ">
  <code>create_extension ::= CREATE EXTENSION [ IF NOT EXISTS ]  extension_name
                       [ WITH ] [ SCHEMA schema_name ]
                       [ VERSION version ] [ CASCADE ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>SCHEMA, VERSION和CASCADE可以乱序。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f2c11c3" class="language-sql ">
  <code>CREATE SCHEMA myschema;</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="270b2ea" class="language-sql ">
  <code>CREATE EXTENSION pgcrypto WITH SCHEMA myschema VERSION  &#39;1.3&#39;;</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="969cfba" class="language-sql ">
  <code>CREATE EXTENSION IF NOT EXISTS earthdistance CASCADE;</code>
  </pre>
  </div>
<h2 id="create-function">CREATE FUNCTION <a href="#create-function" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE FUNCTION语句在数据库中定义新功能。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="23c6d65" class="language- ">
  <code>create_function ::= CREATE [ OR REPLACE ] FUNCTION name  (
                      [ arg_decl [ , ... ] ] )
                      [ RETURNS type_name
                         | RETURNS TABLE ( { column_name type_name }
                            [ , ... ] ) ]
                      { LANGUAGE lang_name
                         | TRANSFORM { FOR TYPE type_name } [ , ... ]
                         | WINDOW
                         | IMMUTABLE
                         | STABLE
                         | VOLATILE
                         | [ NOT ] LEAKPROOF
                         | CALLED ON NULL INPUT
                         | RETURNS NULL ON NULL INPUT
                         | STRICT
                         | [ EXTERNAL ] SECURITY INVOKER
                         | [ EXTERNAL ] SECURITY DEFINER
                         | PARALLEL { UNSAFE |  RESTRICTED | SAFE }
                         | COST int_literal
                         | ROWS int_literal
                         | SET configuration_parameter
                            { TO value | = value | FROM CURRENT }
                         | AS &#39;definition&#39;
                         | AS &#39;obj_file&#39; &#39;link_symbol&#39; } [ ... ]

arg_decl ::= [ argmode ] [ argname ] argtype
                [ {  DEFAULT | = } expression ] </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>
<p>如果给定name和参数类型的函数已经存在，那么CREATE     FUNCTION除非使用CREATE     OR REPLACE FUNCTION版本，否则将引发错误。在这种情况下，它将替换任何现有定义。</p>
</li>
<li>
<p>默认支持的语言包括sql，plpgsql和C</p>
</li>
<li>
<p>VOLATILE，STABLE并IMMUTABLE告知查询优化器该函数的行为。</p>
</li>
<li>
<ul>
<li>VOLATILE是默认值，表示每个调用的函数结果可能不同。例如random()或now()。</li>
<li>STABLE 表示该函数不会修改数据库，因此在一次扫描中，如果给定相同的参数，它将返回相同的结果。</li>
<li>IMMUTABLE表示该函数不会修改数据库，并且在给定相同参数的情况下始终返回相同结果。</li>
</ul>
</li>
<li>
<p>CALLED ON NULL INPUT，RETURNS NULL ON NULL INPUT和STRICT定义函数对于“ null”的行为。</p>
</li>
<li>
<ul>
<li>CALLED ON NULL INPUT指示输入参数可能是null。</li>
<li>RETURNS NULL ON NULL INPUT或STRICT表示函数在输入任何null参数时总是返回null。</li>
</ul>
</li>
</ul>
<p><strong>例子</strong></p>
<p>使用SQL语言定义函数。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5c33d83" class="language-sql ">
  <code>CREATE FUNCTION mul(integer, integer) RETURNS integer
    AS &#39;SELECT $1  * $2;&#39;
    LANGUAGE SQL
    IMMUTABLE
    RETURNS NULL ON NULL INPUT;

SELECT mul(2,3), mul(10, 12);</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2504372" class="language- ">
  <code>mul | mul
-----&#43;-----
    6 | 120
(1 row)  </code>
  </pre>
  </div>
<p>使用PL/pgSQL定义一个函数</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="be13b01" class="language-sql ">
  <code>CREATE OR REPLACE FUNCTION inc(i integer) RETURNS  integer AS $$
        BEGIN
               RAISE NOTICE &#39;Incrementing %&#39;, i ;
               RETURN i &#43; 1;
        END;

$$ LANGUAGE plpgsql;

SELECT inc(2), inc(5), inc(10);  </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="34dd2e5" class="language- ">
  <code>NOTICE:   Incrementing 2
NOTICE:   Incrementing 5
NOTICE:   Incrementing 10
inc | inc | inc
-----&#43;-----&#43;-----
3 |  6 |   11
(1 row)  </code>
  </pre>
  </div>
<h2 id="create-group">CREATE GROUP <a href="#create-group" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE GROUP语句创建组角色。CREATE GROUP是 CREATE ROLE的 别名。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="854b450" class="language- ">
  <code>create_group  ::= CREATE GROUP role_name
                    [ [ WITH ] role_option [ ,  ... ] ]

role_option  ::= SUPERUSER
                   | NOSUPERUSER
                   | CREATEDB
                   | NOCREATEDB
                   | CREATEROLE
                   | NOCREATEROLE
                   | INHERIT
                   | NOINHERIT
                   | LOGIN
                   | NOLOGIN
                   | CONNECTION LIMIT connlimit
                   | [ ENCRYPTED ] PASSWORD &#39; password &#39;
                   | PASSWORD NULL
                   | VALID UNTIL &#39; timestamp &#39;
                   | IN ROLE role_name [ , ... ]
                   | IN GROUP role_name [ , ...  ]
                   | ROLE role_name [ , ... ]
                   | ADMIN role_name [ , ... ]
                   | USER role_name [ , ... ]
                   | SYSID uid  </code>
  </pre>
  </div>
<p><strong>例子</strong></p>
<p>创建一个名为sample的组，可以管理数据库和角色。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="48fa637" class="language-sql ">
  <code>CREATE GROUP SysAdmin WITH  CREATEDB CREATEROLE;</code>
  </pre>
  </div>
<h2 id="create-index">CREATE INDEX <a href="#create-index" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE INDEX语句在指定表的指定列上创建索引。索引主要用于提高查询性能。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="3ab5a3f" class="language- ">
  <code>create_index ::= CREATE [ UNIQUE ] INDEX [ [ IF NOT  EXISTS ] name ]
                   ON [ ONLY ] table_name ( index_elem [ , ... ] )
                   [ INCLUDE ( column_name [ , ... ] ) ]
                   [ WHERE predicate ]

index_elem ::= { column_name | ( expression ) }
                  [  operator_class_name ] [ HASH | ASC | DESC ]
                  [  NULLS { FIRST | LAST } ] </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>UNIQUE 强制要求不允许表中出现重复值</p>
<p>INCLUDE指定将作为非关键列包含在索引中的列集合。</p>
<p>WHERE部分索引是建立在只包括满足所where规定的条件的行组成的表的子集的索引。它可用于从索引中排除NULL或公共值，或仅包含感兴趣的行。这将加快对表的写入速度，因为不需要索引包含公共列值的行。它还将减小索引的大小，从而提高使用该索引的读取查询的速度。</p>
<p>name 指定要创建的索引的名称。</p>
<p>table_name 指定要建立索引的表的名称。</p>
<p>column_name 指定表的列名。</p>
<p>expression 指定表的一列或多列，并且必须用括号括起来。</p>
<ul>
<li>HASH-使用列的哈希值。这是第一列的默认选项，用于对索引表进行哈希分区。</li>
<li>ASC—升序排列。这是索引的第二列和后续列的默认选项。</li>
<li>DESC —降序排列。</li>
<li>NULLS FIRST-指定null排在非null之前。当指定DESC时，这是默认设置。</li>
<li>NULLS LAST-指定null排在非null之后。如果未指定DESC，则为默认设置。</li>
</ul>
<p>SPLIT INTO 对于散列索引，可以使用该SPLIT INTO子句指定要为索引创建的tablet的数量。使用 SPLIT INTO 预先分割索引可索引将工作负载分配到生产集群上。例如，如果您有3台服务器，则将索引分为30个tablet可以提供更高的索引写吞吐量。</p>
<p><strong>例子</strong></p>
<p>创建具有哈利排序列的唯一索引。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="05ccea9" class="language-sql ">
  <code>CREATE TABLE products(id int PRIMARY KEY,
                               name text,
                               code text);

CREATE UNIQUE INDEX ON products(code);</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="739e53a" class="language- ">
  <code>\d products
             Table &#34;public.products&#34;
Column | Type   | Collation | Nullable | Default
--------&#43;---------&#43;-----------&#43;----------&#43;---------
id   | integer |      | not null |
name  | text    |      |     |
code  | text    |      |     |

Indexes:
    &#34;products_pkey&#34; PRIMARY KEY, lsm (id HASH)
    &#34;products_code_idx&#34; UNIQUE, lsm (code HASH)  </code>
  </pre>
  </div>
<p>用升序键创建索引。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="14977db" class="language- ">
  <code>CREATE INDEX products_name ON products(name ASC);
\d products_name
    Index &#34;public.products_name&#34;
Column | Type |  Key? | Definition
--------&#43;------&#43;------&#43;------------
name  | text | yes | name
lsm, for table &#34;public.products</code>
  </pre>
  </div>
<p>创建具有升序排序键的索引，并包括其他列作为非键列。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="baa6388" class="language- ">
  <code>CREATE INDEX products_name_code ON products(name)  INCLUDE (code);
\d products_name_code;
 Index  &#34;public.products_name_code&#34;
 Column | Type |  Key? | Definition
--------&#43;------&#43;------&#43;------------
name  | text | yes | name
code  | text | no  | code
lsm, for table &#34;public.products&#34;</code>
  </pre>
  </div>
<p>指定索引的tablet数量。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c1ca156" class="language-sql ">
  <code>CREATE TABLE employees (id int PRIMARY KEY, first_name  TEXT, last_name TEXT) SPLIT INTO 10 TABLETS;

CREATE INDEX ON employees(first_name, last_name) SPLIT  INTO 10 TABLETS;</code>
  </pre>
  </div>
<p>一个维护货运信息的应用程序。它有一个shipments表，该表的列为delivery_status。如果应用程序需要频繁访问 shipments表 ，则可以使用部分索引排除货件状态为 delivered 的行。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d34dcce" class="language-sql ">
  <code>create table shipments(id int, delivery_status text,  address text, delivery_date date);

create index shipment_delivery on  shipments(delivery_status, address, delivery_date) where delivery_status !=  &#39;delivered&#39;; </code>
  </pre>
  </div>
<h2 id="create-operator">CREATE OPERATOR <a href="#create-operator" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE OPERATOR语句创建一个新的运算符。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="cd59041" class="language- ">
  <code>create_operator ::= CREATE OPERATOR operator_name (
                       { FUNCTION = function_name
                          | PROCEDURE = procedure_name }
                       [ , operator_option [ ... ] ] )

operator_option ::= LEFTARG = left_type
                       | RIGHTARG = right_type
                       | COMMUTATOR = com_op
                       | NEGATOR = neg_op
                       | RESTRICT = res_proc
                       | JOIN = join_proc
                       | HASHES
                       | MERGES</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-create-operator]中每个选项的语义。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="20a13c7" class="language-sql ">
  <code>CREATE OPERATOR @#@ (
           rightarg = int8,
           procedure = numeric_fac
        );

SELECT @#@ 5;  </code>
  </pre>
  </div>
<h2 id="create-operator-class">CREATE OPERATOR CLASS <a href="#create-operator-class" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE OPERATOR CLASS语句创建一个新的运算符类。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="baf984e" class="language- ">
  <code>reate_operator_class ::= CREATE OPERATOR CLASS  operator_class_name
                             [ DEFAULT ] FOR  TYPE data_type USING
                             index_method AS  operator_class_as [ , ... ]

operator_class_as ::= OPERATOR strategy_number  operator_name
                         [ ( operator_signature ) ] [ FOR SEARCH ]
                         | FUNCTION support_number
                            [ ( op_type [ , ... ] ) ] function_name (
                            function_signature )
                         | STORAGE storage_type</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-create-op-class]中每个选项的语义。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5dbf9f5" class="language-sql ">
  <code>CREATE OPERATOR CLASS my_op_class
         FOR  TYPE int4
         USING  btree AS
         OPERATOR 1 &lt;,
         OPERATOR 2 &lt;=;</code>
  </pre>
  </div>
<h2 id="create-policy">CREATE POLICY <a href="#create-policy" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE POLICY语句为表创建新的行级安全策略。策略授予SELECT，INSERT，UPDATE或DELETE访问匹配表达式的行的权限。必须使用ALTER TABLE在表上启用行级安全性，策略才能生效。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2411cd5" class="language- ">
  <code>create_policy ::= CREATE POLICY name ON table_name
                     [ AS { PERMISSIVE | RESTRICTIVE } ]
                     [ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ]
                     [ TO { role_name
                             | PUBLIC
                             | CURRENT_USER
                             | SESSION_USER } [ , ... ] ]
                     [ USING ( using_expression ) ]
                     [ WITH CHECK ( check_expression ) ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>name是新政策的名称。该名称必须不同于该表的任何其他策略名称。</li>
<li>table_name 是策略适用的表的名称。</li>
<li>PERMISSIVE/ RESTRICTIVE指定该策略是允许的还是限制性的。在将策略应用于表时，使用逻辑OR运算符将宽松的策略组合在一起，而使用逻辑AND运算符将限制性策略组合在一起。限制性策略用于减少可访问的记录数。默认值是允许的。</li>
<li>role_name是应用策略的角色。默认值是PUBLIC将策略应用于所有角色。</li>
<li>using_expression是SQL条件表达式。条件变为true的行仅在中可见，SELECT而在UPDATE或中可用于修改DELETE。</li>
<li>check_expression是仅用于INSERT和UPDATE 查询的SQL条件表达式。只有行该表达式评估为真将以被允许INSERT或 UPDATE。请注意，与不同using_expression，它是针对该行的建议新内容进行评估的。</li>
</ul>
<p><strong>例子</strong></p>
<p>创建一个宽松的策略。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e5272a0" class="language-sql ">
  <code>CREATE POLICY p1 ON document
  USING (dlevel  &lt;= (SELECT level FROM user_account WHERE user = current_user)); </code>
  </pre>
  </div>
<p>创建限制性策略。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a0329e3" class="language-sql ">
  <code>CREATE POLICY p_restrictive ON document AS RESTRICTIVE  TO user_bob    USING (cid  &lt;&gt; 44); </code>
  </pre>
  </div>
<p>创建一个带有CHECK插入条件的策略。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ba24a16" class="language-sql ">
  <code>CREATE POLICY p2 ON document FOR INSERT WITH CHECK  (dauthor = current_user);  </code>
  </pre>
  </div>
<h2 id="create-procedure">CREATE PROCEDURE <a href="#create-procedure" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE PROCEDURE语句在数据库中定义新存储过程。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5c51a19" class="language- ">
  <code>create_procedure ::= CREATE [ OR REPLACE ] PROCEDURE  name (
                       [ arg_decl [ , ... ] ] )
                       { LANGUAGE lang_name
                          | TRANSFORM { FOR TYPE type_name } [ , ... ]
                          | [ EXTERNAL ] SECURITY INVOKER
                          | [ EXTERNAL ] SECURITY DEFINER
                          | SET configuration_parameter
                             { TO value | = value | FROM  CURRENT }
                          | AS &#39;definition&#39;
                          | AS &#39;obj_file&#39; &#39;link_symbol&#39; } [ ... ]

arg_decl ::= [ argmode ] [ argname ] argtype
                 [ {  DEFAULT | = } expression ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>如果name已经存在具有给定和参数类型的过程，则CREATE     PROCEDURE除非使用该CREATE     OR REPLACE PROCEDURE版本，否则将引发错误。在这种情况下，它将替换任何现有定义。</li>
<li>默认支持的语言包括sql，plpgsql和C。</li>
</ul>
<p><strong>例子</strong></p>
<p>设置一个账户表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="3c57a35" class="language-sql ">
  <code>CREATE TABLE accounts (
   id integer  PRIMARY KEY,
   name text NOT  NULL,
   balance  decimal(15,2) NOT NULL
);

INSERT INTO accounts VALUES (1, &#39;Jane&#39;, 100.00);
INSERT INTO accounts VALUES (2, &#39;John&#39;, 50.00);

SELECT * from accounts; </code>
  </pre>
  </div>
<p>定义transfer将资金从一个账户转移到另一个账户的存储过程。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d322054" class="language-sql ">
  <code>CREATE OR REPLACE PROCEDURE transfer(integer, integer,  decimal)
LANGUAGE plpgsql
AS $$
BEGIN
   IF $3 &lt;=  0.00 then RAISE EXCEPTION &#39;Can only transfer positive amounts&#39;; END IF;
   IF $1 = $2 then  RAISE EXCEPTION &#39;Sender and receiver cannot be the same&#39;; END IF;
   UPDATE accounts  SET balance = balance - $3 WHERE id = $1;
   UPDATE accounts  SET balance = balance &#43; $3 WHERE id = $2;
   COMMIT;
END;
$$;</code>
  </pre>
  </div>
<p>执行转账操作。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="936c167" class="language-sql ">
  <code>CALL transfer(1, 2, 20.00);
SELECT * from accounts;</code>
  </pre>
  </div>
<h2 id="create-role">CREATE ROLE <a href="#create-role" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE ROLE语句向MemFire数据库集群添加新角色。角色是可以拥有数据库对象并具有数据库特权的实体。角色可以是用户或组，具体取决于使用方式。具有 LOGIN 属性的role可以视为user。具有CREATEROLE特权或成为数据库超级用户才能使用此命令。 可以使用GRANT/ REVOKE命令设置/删除角色的权限。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="78f001e" class="language- ">
  <code>create_role ::= CREATE ROLE role_name
                  [ [ WITH ] role_option [ , ... ] ]

role_option ::= SUPERUSER
                  | NOSUPERUSER
                  | CREATEDB
                  | NOCREATEDB
                  | CREATEROLE
                  | NOCREATEROLE
                  | INHERIT
                  | NOINHERIT
                  | LOGIN
                  | NOLOGIN
                  | CONNECTION LIMIT connlimit
                  | [ ENCRYPTED ] PASSWORD &#39; password &#39;
                  | PASSWORD NULL
                  | VALID UNTIL &#39; timestamp &#39;
                  | IN ROLE role_name [ , ... ]
                  | IN GROUP role_name [ , ... ]
                  | ROLE role_name [ , ... ]
                  | ADMIN role_name [ , ... ]
                  | USER role_name [ , ... ]
                  | SYSID uid </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>role_name 是新角色的名称。</li>
<li>SUPERUSER，NOSUPERUSER确定新角色是否是“超级用户”。超级用户可以覆盖所有访问限制，应谨慎使用。只有具有SUPERUSER特权的角色才能创建其他SUPERUSER角色。如果未指定，则默认为NOSUPERUSER。</li>
<li>CREATEDB，NOCREATEDB确定新角色是否可以创建数据库。默认值为NOCREATEDB。</li>
<li>CREATEROLE，NOCREATEROLE确定新角色是否可以创建其他角色。默认值为NOCREATEROLE。</li>
<li>INHERIT，NOINHERIT确定新角色是否继承其所属角色的特权。如果没有INHERIT，则另一个角色的成员资格仅授予SET     ROLE权限给该另一个角色。其他角色的特权只有在这样做后才可用。如果未指定，则默认为INHERIT。</li>
<li>LOGIN，NOLOGIN确定是否允许新角色登录。客户端连接期间只能使用具有登录特权的角色。可以将具有LOGIN的角色视为用户。如果未指定，则默认为NOLOGIN。请注意，如果使用CREATE     USER而不是CREATE     ROLE，则默认值为LOGIN。</li>
<li>CONNECTION LIMIT指定角色可以建立的并发连接数。默认值为-1，表示无限制。这仅适用于可以登录的角色。</li>
<li>[ENCRYPTED] PASSWORD设置新角色的密码。这仅适用于可以登录的角色。如果未指定密码，则密码将设置为null，并且该用户的密码身份验证将始终失败。请注意，密码始终以加密方式存储在系统目录中，并且仅提供可选关键字ENCRYPTED是为了与Postgres兼容。</li>
<li>VALID UNTIL设置一个日期和时间，之后该角色的密码将不再有效。如果省略此子句，则密码将一直有效。</li>
<li>IN ROLE role_name，IN     GROUP role_name列出一个或多个现有角色，新角色将立即作为新成员添加到其中。（请注意，没有选项可以将新角色添加为管理员；请使用单独的GRANT命令来执行此操作。）</li>
<li>ROLE role_name，USER     role_name列出一个或多个现有角色，这些角色将自动添加为新角色的成员。（这实际上使新角色成为“组”。）</li>
<li>ADMIN role_name与相似ROLE     role_name，但是将命名角色添加到使用ADMIN     OPTION的新角色中，从而赋予他们将这个角色的成员资格授予其他人的权利。</li>
<li>SYSID uid 被忽略，并且与Postgres兼容。</li>
</ul>
<p><strong>例子</strong></p>
<p>创建一个可以登录的角色。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="322dccf" class="language-sql ">
  <code>CREATE ROLE John LOGIN;</code>
  </pre>
  </div>
<p>创建一个可以登录并具有密码的juese。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9e0e96a" class="language-sql ">
  <code>CREATE ROLE Jane LOGIN  PASSWORD &#39;password&#39;;</code>
  </pre>
  </div>
<p>创建一个可以管理数据库和角色的角色。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e214646" class="language-sql ">
  <code>CREATE ROLE SysAdmin  CREATEDB CREATEROLE; </code>
  </pre>
  </div>
<h2 id="create-rule">CREATE RULE <a href="#create-rule" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE RULE语句创建新规则。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2dcdf30" class="language- ">
  <code>create_rule  ::= CREATE [ OR REPLACE ] RULE rule_name AS ON rule_event TO table_name [ WHERE  condition ] DO [ ALSO | INSTEAD ] { NOTHING | command | ( command [ ; ... ] )  }

rule_event  ::= SELECT | INSERT | UPDATE | DELETE

command  ::= SELECT | INSERT | UPDATE | DELETE | NOTIFY  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-create-rule]中每个选项的语义。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8371e87" class="language-sql ">
  <code>CREATE TABLE t1(a int4, b int4);
CREATE TABLE t2(a int4, b int4);
CREATE RULE t1_to_t2 AS ON INSERT TO t1 DO INSTEAD
INSERT INTO t2 VALUES (new.a, new.b);
INSERT INTO t1 VALUES (3, 4);
SELECT * FROM t1;</code>
  </pre>
  </div>
<h2 id="create-schema">CREATE SCHEMA <a href="#create-schema" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE SCHEMA语句在当前数据库中创建一个新模式。模式本质上是一个命名空间：它包含命名对象（表，数据类型，函数和运算符），其名称可以与其他模式中存在的其他对象的名称重复。可以通过使用模式名称作为前缀或通过在搜索路径中设置模式名称来访问模式中的命名对象。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="55c9e48" class="language- ">
  <code>create_schema_name ::= CREATE SCHEMA [ IF NOT EXISTS ]  schema_name
                         [ AUTHORIZATION role_specification ]

create_schema_role ::= CREATE SCHEMA [ IF NOT EXISTS ]  AUTHORIZATION                                                role_specification [ schema_element [ ... ] ]

role_specification ::= role_name | CURRENT_USER | SESSION_USER</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>schema_name是要创建的模式的名称。如果未指定schema_name，role_name则使用。</li>
<li>role_name是拥有新模式的角色。如果省略，则默认为用户执行命令。要创建另一个角色拥有的模式，必须是该角色的直接或间接成员，或者是超级用户才能执行。</li>
</ul>
<p><strong>例子</strong></p>
<p>创建一个新的模式。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="42a275e" class="language-sql ">
  <code>CREATE SCHEMA IF NOT EXIST branch;</code>
  </pre>
  </div>
<p>为用户创建模式。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ddfc265" class="language-sql ">
  <code>CREATE ROLE John;
CREATE SCHEMA AUTHORIZATION john;</code>
  </pre>
  </div>
<p>创建一个模式和改模式中的对象。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="b682796" class="language-sql ">
  <code>CREATE SCHEMA branch
            CREATE TABLE dept(
               dept_id INT NOT NULL,
               dept_name TEXT NOT NULL,
               PRIMARY KEY (dept_id)
            ); </code>
  </pre>
  </div>
<h2 id="create-sequence">CREATE SEQUENCE <a href="#create-sequence" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE SEQUENCE语句在当前模式中创建一个新序列。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="32821f8" class="language- ">
  <code>create_sequence ::= CREATE SEQUENCE [ IF NOT EXISTS ]  sequence_name
                       sequence_options

sequence_name ::= &#39;&lt;Text Literal&gt;&#39;

sequence_options ::= [ INCREMENT [ BY ] increment ]
                         [ MINVALUE minvalue | NO MINVALUE ]
                         [ MAXVALUE maxvalue | NO MAXVALUE ]
                         [ START [ WITH ] start ] [ CACHE cache ]
                         [ [ NO ] CYCLE ]</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>CREATE SEQUENCE sequence_name [ IF NOT EXISTS ] 指定序列的名称（sequence_name）。如果在当前模式中已经存在具有该名称的序列，并且IF NOT EXISTS未指定该序列，则会引发错误。</p>
<p>INCREMENT BY increment 指定序列中连续值之间的差。默认值为1。</p>
<p>MINVALUE minvalue | NO MINVALUE 指定序列中允许的最小值。如果达到该值（以负增量递增的顺序），nextval()将返回错误。如果NO MINVALUE指定，则使用默认值。默认值为1。</p>
<p>MAXVALUE maxvalue | NO MAXVALUE 指定序列中允许的最大值。如果达到此值，nextval()将返回错误。如果NO MAXVALUE指定，则使用默认值。默认值为263 - 1。</p>
<p>START WITH start 指定序列中的第一个值。start不能少于minvalue。默认值为1。</p>
<p>CACHE cache 指定序列中要在客户端中缓存的数字。默认值为1。</p>
<p>[ NO ] CYCLE 如果CYCLE已指定，则序列到达minvalue或时将环绕maxvalue。如果maxvalue达到，minvalue将是序列中的下一个数字。如果minvalue达到（对于降序序列），maxvalue将是序列中的下一个数字。NO CYCLE是默认值。</p>
<p>Cache 在PostgreSQL中，在MSQL中，序列的数据存储在持久性系统表中。在MSQL中，此表每个序列有一行，并且它以两个值存储序列数据： last_val 存储上次使用的值或下一个要使用的值。 is_called 存储是否last_val已使用。如果为false，last_val则为序列中的下一个值。否则，last_val+ INCREMENT是下一个。</p>
<p>默认情况下（INCREMENT为1时），每次调用都会nextval()更新last_val该序列。在MSQL中，复制包含序列数据的表，而不是将其复制到本地文件系统中。对该表的每次更新都需要两个RPC（并且将来将优化为一个RPC），无论如何，nextval()在MSQL中调用所经历的延迟将大大高于Postgres中的相同操作。为了避免这种性能下降，MemFire建议使用具有足够大值的缓存值。缓存的值存储在本地节点的内存中，检索这些值可以避免任何RPC，因此可以在为缓存分配的所有编号上摊销一次缓存分配的延迟。</p>
<p>SERIAL类型创建的序列具有默认值为1的缓存。因此，应避免使用 SERIAL 类型，而应使用其等效语句。而不是创建具有以下SERIAL类型的表：</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="da445b7" class="language- ">
  <code>CREATE TABLE t(k SERIAL)</code>
  </pre>
  </div>
<p>您应该创建一个足够大的缓存序列，然后设置列，你想有一个串行类型DEFAULT以nextval()序列。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f1c199e" class="language- ">
  <code>CREATE SEQUENCE t_k_seq CACHE 10000;
CREATE TABLE t(k integer NOT NULL DEFAULT  nextval(&#39;t_k_seq&#39;));</code>
  </pre>
  </div>
<p><strong>例子</strong></p>
<p>创建一个简单的序列，每个nextval()调用时递增1。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f2b501b" class="language-sql ">
  <code>CREATE SEQUENCE s; </code>
  </pre>
  </div>
<p>调用nextval()。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="b40a980" class="language-sql ">
  <code>SELECT nextval(&#39;s&#39;);  </code>
  </pre>
  </div>
<p>创建一个具有10,000个 缓存 值的序列。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e1caf3c" class="language-sql ">
  <code>CREATE SEQUENCE s2 CACHE  10000;</code>
  </pre>
  </div>
<p>在第一个会话中调用nextval()。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="91c8065" class="language- ">
  <code>SELECT nextval(&#39;s2&#39;);
 nextval
---------
          1
(1 row)  </code>
  </pre>
  </div>
<p>在第二个会话中调用 nextval()。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2912836" class="language- ">
  <code>SELECT nextval(&#39;s2&#39;);
nextval
---------
      10001
(1 row)</code>
  </pre>
  </div>
<p>创建一个从0开始的序列。将MINVALUE从其默认值1更改为小于或等于0的值。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ca701d8" class="language- ">
  <code>CREATE SEQUENCE s3 START 0 MINVALUE 0;
CREATE SEQUENCE
SELECT nextval(&#39;s3&#39;);
nextval
---------
          0
(1 row)</code>
  </pre>
  </div>
<h2 id="create-table">CREATE TABLE <a href="#create-table" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE TABLE语句在数据库中创建新表。它定义了表名，列名和类型，主键和表属性。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e828033" class="language- ">
  <code>create_table ::= CREATE [ TEMPORARY | TEMP ] TABLE [ IF  NOT EXISTS ]
                    table_name ( [ table_elem [ , ... ] ] )
                    [ WITH ( { COLOCATED = { &#39;true&#39; | &#39;false&#39; }
                                 | storage_parameters } )
                       | WITHOUT OIDS ]
                    [ SPLIT { INTO integer TABLETS
                               | AT VALUES ( split_row [ , ... ] ) } ]

table_elem ::= column_name data_type [  column_constraint [ ... ] ]
                 | table_constraint

column_constraint ::= [ CONSTRAINT constraint_name ]
                          { NOT NULL
                             | NULL
                             | CHECK ( expression )
                             | DEFAULT expression
                             | UNIQUE index_parameters
                             | PRIMARY KEY
                             | references_clause }
                          [ DEFERRABLE | NOT DEFERRABLE ]
                          [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]

table_constraint ::= [ CONSTRAINT constraint_name ]
                          { CHECK ( expression )
                             | UNIQUE ( column_names ) index_parameters
                             | PRIMARY KEY ( key_columns )
                             | FOREIGN KEY ( column_names )
                                references_clause }
                          [ DEFERRABLE | NOT DEFERRABLE ]
                          [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]

key_columns ::= hash_columns [ , range_columns ] |  range_columns

hash_columns ::= column_name [ HASH ] | ( column_name [  , ... ] ) HASH

range_columns ::= { column_name { ASC | DESC } } [ ,  ... ]

storage_parameters ::= storage_parameter [ , ... ]

storage_parameter ::= param_name [ = param_value ]

index_parameters ::= [ INCLUDE ( column_names ) ]
                         [ WITH ( storage_parameters ) ]

references_clause ::= REFERENCES table_name [  column_name [ , ... ] ]
                         [ MATCH FULL | MATCH PARTIAL | MATCH  SIMPLE ]
                         [ ON DELETE key_action ]
                         [ ON UPDATE key_action ]

split_row ::= ( column_value [ , ... ] )  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>Primary key 可以在column_constraint或table_constraint 中定义主键 ，但不能在两个地方同时定义。有两种类型的主键列：</p>
<ul>
<li>Hash primary key columns：主键可能具有零个或多个前导哈希分区列。默认情况下，仅第一列被视为哈希分区列。但是可以通过显式使用HASH注释来修改此行为。</li>
<li>Range primary key columns：一个表可以具有零个或多个范围主键列，并且它控制表中行的顶级排序（如果没有哈希分区列）或共享一组公共哈希分区列的行之间的行顺序价值观。默认情况下，范围主键列以升序存储。但是，可以通过显式使用ASC或来控制此行为DESC。</li>
</ul>
<p>Foreign key 这将强制UNIQUE约束中指定的列集在表中是唯一的，也就是说，约束中指定的列集的任何两行都不能具有相同的值。</p>
<p>Check 这用于强制指定表中的数据满足该CHECK子句中指定的要求。</p>
<p>Default 此子句用于指定列的默认值。如果INSERT语句未为该列指定值，则使用默认值。如果没有为列指定默认值，则默认值为NULL。</p>
<p>Deferrable constraints 可以使用该DEFERRABLE子句推迟约束。当前，在MemFire中只能推迟外键约束。在语句中的每一行之后，将检查不可延迟的约束。在推迟约束的情况下，约束的检查可以推迟到事务结束。</p>
<p>标记为的约束INITIALLY IMMEDIATE将在语句中的每一行之后进行检查。 标记为的约束INITIALLY DEFERRED将在事务结束时检查。</p>
<p>Temporary or Temp 使用此限定符将创建一个临时表。临时表仅在创建它们的当前客户端会话或事务中可见，并在会话或事务结束时自动删除。在临时表上创建的所有索引也是临时的。 SPLIT INTO 对于哈希表，您可以使用该SPLIT INTO子句来指定要为该表创建的tablet。然后，将哈希范围平均分配给这些tablet。</p>
<p><strong>例子</strong></p>
<p>带主键的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="34dc346" class="language-sql ">
  <code>CREATE TABLE sample(k1 int,
                              k2 int,
                              v1 int,
                              v2 text,
                              PRIMARY KEY  (k1, k2));  </code>
  </pre>
  </div>
<p>带范围主键的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="aaf5645" class="language-sql ">
  <code>CREATE TABLE range(k1 int,
                              k2 int,
                              v1 int,
                              v2 text,
                              PRIMARY KEY (k1  ASC, k2 DESC));  </code>
  </pre>
  </div>
<p>带有检查约束的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e21e412" class="language-sql ">
  <code>CREATE TABLE student_grade(student_id int,
                                          class_id int,
                                          term_id  int,
                                          grade  int CHECK (grade &gt;= 0 AND grade &lt;= 10),
                                          PRIMARY  KEY (student_id, class_id, term_id));</code>
  </pre>
  </div>
<p>具有默认值的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a26bd91" class="language-sql ">
  <code>CREATE TABLE cars(id int PRIMARY KEY,
                             brand text CHECK  (brand in (&#39;X&#39;, &#39;Y&#39;, &#39;Z&#39;)),
                             model text NOT  NULL,
                             color text NOT  NULL DEFAULT &#39;WHITE&#39; CHECK (color in (&#39;RED&#39;, &#39;WHITE&#39;, &#39;BLUE&#39;)));  </code>
  </pre>
  </div>
<p>带有外键约束的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f3ddf27" class="language-sql ">
  <code>CREATE TABLE products(id int PRIMARY KEY,
                                 descr text);

CREATE TABLE orders(id int PRIMARY KEY,
                                 pid int REFERENCES  products(id) ON DELETE CASCADE,
                                 amount int); </code>
  </pre>
  </div>
<p>具有唯一约束的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ce31677" class="language-sql ">
  <code>CREATE TABLE translations(message_id int UNIQUE,
                                       message_txt text);</code>
  </pre>
  </div>
<p>创建一个指定分片数量的表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2626e76" class="language-sql ">
  <code>CREATE TABLE tracking (id  int PRIMARY KEY) SPLIT INTO 10 TABLETS;  </code>
  </pre>
  </div>
<p>使用并置表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f54ff13" class="language-sql ">
  <code>CREATE DATABASE company WITH colocated = true;

CREATE TABLE employee(id INT PRIMARY KEY, name TEXT)  WITH (colocated = false);</code>
  </pre>
  </div>
<h2 id="create-table-as">CREATE TABLE AS <a href="#create-table-as" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该CREATE TABLE AS语句使用子查询的输出来创建新表。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="16d1cd8" class="language- ">
  <code>create_table_as ::= CREATE TABLE [ IF NOT EXISTS ] table_name
                      [ ( column_name [ , ... ] ) ]   AS query
                      [ WITH [ NO ] DATA ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>CREATE TABLE [ IF NOT EXISTS ] table_name 创建一个表。</p>
<p>table_name 指定表的名称。</p>
<p>( column_name [ , &hellip; ] ) 指定新表中的列名。未指定时，列名称取自查询的输出列名称。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e235569" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text,  PRIMARY KEY (k1, k2));  </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="60d503f" class="language-sql ">
  <code>INSERT INTO sample VALUES (1, 2.0, 3, &#39;a&#39;), (2, 3.0, 4,  &#39;b&#39;), (3, 4.0, 5, &#39;c&#39;);  </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e2a30b4" class="language-sql ">
  <code>CREATE TABLE selective_sample SELECT * FROM sample  WHERE k1 &gt; 1;  </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="045ce3f" class="language-sql ">
  <code>SELECT * FROM selective_sample ORDER BY k1; </code>
  </pre>
  </div>
<h2 id="create-trigger">CREATE TRIGGER <a href="#create-trigger" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE TRIGGER语句定义新的触发器。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9ea3975" class="language- ">
  <code>create_trigger ::= CREATE TRIGGER name { BEFORE | AFTER  | INSTEAD OF }
                      { event [ OR ... ] } ON table_name
                      [ FROM table_name ] [ NOT  DEFERRABLE ]
                      [ FOR [ EACH ] { ROW | STATEMENT } ]
                      [ WHEN ( condition ) ] EXECUTE
                      { FUNCTION | PROCEDURE } function_name (
                      function_arguments )

event ::= INSERT
            | UPDATE [ OF column_name [ , ... ] ]
            | DELETE
            | TRUNCATE  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>WHEN条件可用于指定是否应触发触发器。对于低级触发器，它可以引用该行的列的旧值和/或新值。</li>
<li>可以为同一事件定义多个触发器。在这种情况下，将按名称的字母顺序将其触发。</li>
</ul>
<p><strong>例子</strong></p>
<p>设置带有触发器的表，以跟踪修改时间和用户（角色）。使用预安装的扩展insert_username和moddatetime。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e389864" class="language-sql ">
  <code>CREATE EXTENSION insert_username;

CREATE EXTENSION moddatetime;

CREATE TABLE posts (
   id int primary key,
   content text,
   username text not null,
   moddate timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
);

CREATE TRIGGER insert_usernames
   BEFORE INSERT OR UPDATE ON posts
   FOR EACH ROW
   EXECUTE  PROCEDURE insert_username (username);
   
CREATE TRIGGER update_moddatetime
   BEFORE UPDATE  ON posts
   FOR EACH ROW
   EXECUTE  PROCEDURE moddatetime (moddate);  </code>
  </pre>
  </div>
<p>插入一些行。对于每次插入，触发器应将当前角色设置为username，将当前时间戳设置为moddate。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9b5227e" class="language-sql ">
  <code>SET ROLE memfire;
INSERT INTO posts VALUES(1, &#39;desc1&#39;);

SET ROLE postgres;
INSERT INTO posts VALUES(2, &#39;desc2&#39;);
INSERT INTO posts VALUES(3, &#39;desc3&#39;);

SET ROLE memfire;
INSERT INTO posts VALUES(4, &#39;desc4&#39;);

SELECT * FROM posts ORDER BY id;</code>
  </pre>
  </div>
<p>更新一些行。对于每一个更新的触发器既设置username和moddate相应。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="37c4fc2" class="language-sql ">
  <code>UPDATE posts SET content = &#39;desc1_updated&#39; WHERE id = 1;
UPDATE posts SET content = &#39;desc3_updated&#39; WHERE id = 3;

SELECT * FROM posts ORDER BY id;</code>
  </pre>
  </div>
<h2 id="create-type">CREATE TYPE <a href="#create-type" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE TYPE语句在数据库中创建新的用户定义类型。有五种类型：复合，枚举，范围，基数和shell。每个都有自己的CREATE TYPE语法。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c9a4263" class="language- ">
  <code>create_composite_type ::= CREATE TYPE type_name AS (
                            [ composite_type_elem [ , ... ] ] )

create_enum_type ::= CREATE TYPE type_name AS ENUM (
                        [ label [ , ... ] ] )

create_range_type ::= CREATE TYPE type_name AS RANGE (  SUBTYPE =
                         subtype [ , range_type_option [ ... ] ] )

create_base_type ::= CREATE TYPE type_name ( INPUT =  input_function ,
                            OUTPUT = output_function
                            [ , base_type_option [ ... ] ] )

create_shell_type ::= CREATE TYPE type_name

composite_type_elem ::= attribute_name data_type [  COLLATE collation ]

range_type_option ::= SUBTYPE_OPCLASS =  subtype_operator_class
                         | COLLATION = collation
                         | CANONICAL = canonical_function
                         | SUBTYPE_DIFF = subtype_diff_function

base_type_option ::= RECEIVE = receive_function
                        | SEND = send_function
                        | TYPMOD_IN = type_modifier_input_function
                        | TYPMOD_OUT = type_modifier_output_function
                        | INTERNALLENGTH = { internallength | VARIABLE }
                        | PASSEDBYVALUE
                        | ALIGNMENT = alignment
                        | STORAGE = storage
                        | LIKE = like_type
                        | CATEGORY = category
                        | PREFERRED = preferred
                        | DEFAULT = default
                        | ELEMENT = element
                        | DELIMITER = delimiter
                        | COLLATABLE = collatable </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>base_type_option</p>
<ul>
<li>type_name 指定此用户定义类型的名称。</li>
<li>attribute_name 指定此复合类型的属性的名称。</li>
<li>data_type 指定此复合类型的属性的类型。</li>
<li>collation指定用于此类型的排序规则。如果这是复合类型，则属性数据类型必须可合并。如果这是范围类型，则子类型必须可排序。</li>
<li>label 指定带引号的标签为此枚举类型的值。</li>
<li>subtype 指定用于此范围类型的类型。</li>
<li>subtype_operator_class 指定用于此范围类型的子类型的运算符类。</li>
<li>canonical_function 指定在将此范围类型的范围值转换为规范形式时使用的规范函数。</li>
<li>subtype_diff_function 指定用于获取此范围类型的两个范围值之间的差的子类型差函数。</li>
<li>input_function 指定将此类型的外部文本表示转换为内部表示的函数。</li>
<li>output_function 指定将此类型的内部表示形式转换为外部文本表示形式的函数。</li>
<li>receive_function 指定将此类型的外部二进制表示形式转换为内部表示形式的函数。</li>
<li>send_function 指定将此类型的内部表示形式转换为外部二进制表示形式的函数。</li>
<li>type_modifier_input_function 指定将此类型修饰符的外部文本表示形式转换为内部整数typmod值或引发错误的函数。</li>
<li>type_modifier_output_function 指定将此类型修饰符的内部整数typmod值转换为外部表示形式的函数。</li>
<li>internallength 指定此类型的大小（以字节为单位）。</li>
<li>alignment 指定此类型的存储对齐方式。</li>
<li>storage指定此类型的存储策略。此类型必须是可变长度。</li>
<li>like_type指定到拷贝过来的类型INTERNALLENGTH，PASSEDBYVALUE，ALIGNMENT，和STORAGE的值从。</li>
<li>category 指定此类型的类别代码。</li>
<li>preferred 指定对于同一类别中的隐式强制转换是否首选此类型。</li>
<li>default 指定此类型的默认值。</li>
<li>element 指定此类型的元素，也使该类型成为数组。</li>
<li>delimiter 指定用于在此类型的值的外部文本表示形式中分隔数组元素的字符。</li>
<li>collatable 指定是否可以将排序规则信息传递给使用此类型的操作。</li>
</ul>
<p><strong>例子</strong></p>
<p>复合型。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="16c1066" class="language-sql ">
  <code>CREATE TYPE feature_struct AS (id INTEGER, name TEXT);
CREATE TABLE feature_tab_struct (feature_col feature_struct);</code>
  </pre>
  </div>
<p>枚举类型。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2fdb19e" class="language-sql ">
  <code>CREATE TYPE feature_enum AS ENUM (&#39;one&#39;, &#39;two&#39;, &#39;three&#39;);
CREATE TABLE feature_tab_enum (feature_col  feature_enum);</code>
  </pre>
  </div>
<p>范围类型。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f220fe0" class="language-sql ">
  <code>CREATE TYPE feature_range AS RANGE (subtype=INTEGER);
CREATE TABLE feature_tab_range (feature_col feature_range);  </code>
  </pre>
  </div>
<p>基本类型。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="7a28b29" class="language-sql ">
  <code>CREATE TYPE int4_type;
CREATE FUNCTION int4_type_in(cstring) RETURNS int4_type
            LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS &#39;int4in&#39;;
CREATE FUNCTION int4_type_out(int4_type) RETURNS  cstring
            LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS &#39;int4out&#39;;
CREATE TYPE int4_type (
            INPUT = int4_type_in,
            OUTPUT = int4_type_out,
            LIKE = int4
         );
CREATE TABLE int4_table (t int4_type);  </code>
  </pre>
  </div>
<p>外壳类型。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="675b4b4" class="language-sql ">
  <code>CREATE TYPE shell_type;  </code>
  </pre>
  </div>
<h2 id="create-user">CREATE USER <a href="#create-user" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE USER语句创建用户。该CREATE USER语句是 CREATE ROLE 的别名，但默认情况下会创建一个具有LOGIN特权的角色。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c2bb81c" class="language- ">
  <code>create_user ::= CREATE USER role_name
                  [ [ WITH ] role_option [ , ... ] ]

role_option ::= SUPERUSER
                  | NOSUPERUSER
                  | CREATEDB
                  | NOCREATEDB
                  | CREATEROLE
                  | NOCREATEROLE
                  | INHERIT
                  | NOINHERIT
                  | LOGIN
                  | NOLOGIN
                  | CONNECTION LIMIT connlimit
                  | [ ENCRYPTED ] PASSWORD &#39; password &#39;
                  | PASSWORD NULL
                  | VALID UNTIL &#39; timestamp &#39;
                  | IN ROLE role_name [ , ... ]
                  | IN GROUP role_name [ , ... ]
                  | ROLE role_name [ , ... ]
                  | ADMIN role_name [ , ... ]
                  | USER role_name [ , ... ]          |  SYSID uid </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>参阅CREATE ROLE</p>
<p><strong>例子</strong></p>
<p>使用密码创建一个示例用户。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c620f4b" class="language-sql ">
  <code>CREATE USER John WITH PASSWORD &#39;password&#39;; </code>
  </pre>
  </div>
<p>向John授予对MemFire数据库的所有权限。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="41691e9" class="language-sql ">
  <code>GRANT ALL ON DATABASE MemFire TO John;  </code>
  </pre>
  </div>
<p>从MemFire数据库中删除John的权限。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="92707c0" class="language-sql ">
  <code>REVOKE ALL ON DATABASE MemFire FROM John;  </code>
  </pre>
  </div>
<h2 id="create-view">CREATE VIEW <a href="#create-view" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用CREATE VIEW语句在数据库中创建新视图。它定义了视图名称和定义它的（选择）语句。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="4929b86" class="language- ">
  <code>create_view ::= CREATE VIEW qualified_name
                   [ ( column_list ) ] AS select</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>CREATE VIEW qualified_name [ (column_list ) ] AS select 创建一个视图。</p>
<p>qualified_name 指定视图的名称。如果指定数据库中已经存在具有该名称的视图，则会引发错误（除非使用了该OR REPLACE选项）。</p>
<p>column_list 指定以逗号分隔的列列表。如果未指定，则从查询中推导出列名。 select 指定SELECT或VALUES语句，以提供视图的列和行。</p>
<p><strong>例子</strong></p>
<p>创建一个sample表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="4efe814" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text,  PRIMARY KEY (k1, k2));</code>
  </pre>
  </div>
<p>插入一些行。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5be6158" class="language-sql ">
  <code>INSERT INTO sample(k1, k2, v1, v2) VALUES (1, 2.0, 3,  &#39;a&#39;), (2, 3.0, 4, &#39;b&#39;), (3, 4.0, 5, &#39;c&#39;);</code>
  </pre>
  </div>
<p>在sample表上创建一个视图。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9d747a1" class="language-sql ">
  <code>CREATE VIEW sample_view AS SELECT * FROM sample WHERE  v2 != &#39;b&#39; ORDER BY k1 DESC;</code>
  </pre>
  </div>
<p>从视图中选择。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="0ffc6b0" class="language-sql ">
  <code>SELECT * FROM sample_view;</code>
  </pre>
  </div>
<h2 id="dellocate">DELLOCATE <a href="#dellocate" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DEALLOCATE语句取消分配先前准备的SQL语句。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="13674fd" class="language- ">
  <code>deallocate ::= DEALLOCATE [ PREPARE ] { name | ALL } </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>name 指定要释放的准备好的语句的名称。</p>
<p>ALL 取消分配所有准备好的语句。</p>
<p><strong>例子</strong></p>
<p>准备并取消插入语句。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c0800e3" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text,  PRIMARY KEY (k1, k2));
PREPARE ins (bigint, double precision, int, text) AS
               INSERT INTO sample(k1, k2, v1, v2) VALUES ($1, $2, $3, $4);
DEALLOCATE ins;  </code>
  </pre>
  </div>
<h2 id="delete">DELETE <a href="#delete" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DELETE语句删除满足某些条件的行，并且当WHERE子句中未提供条件时，将删除所有行。DELETE输出要删除的行数。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e2c6e01" class="language- ">
  <code>delete ::= [ WITH [ RECURSIVE ] with_query [ , ... ]  ] DELETE FROM
              [ ONLY  ] table_name [ * ] [ [ AS ] alias ]
              [  WHERE condition | WHERE CURRENT OF cursor_name ]
              [ returning_clause ]

returning_clause ::= RETURNING { * | {  output_expression
                                         [ [ AS ]  output_name ] }
                                         [ , ...  ] }  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>USING 子句尚不支持。</li>
<li>尽管该WHERE子句允许使用多种运算符，但该WHERE子句中使用的确切条件具有重要的性能考虑因素（特别是对于大型数据集）。为了获得最佳性能，请使用WHERE为PRIMARY KEY或中的所有列提供值的子句INDEX     KEY。</li>
</ul>
<p>with_query 指定在DELETE语句中按名称引用的子查询。</p>
<p>table_name 指定要删除的表的名称。</p>
<p>alias 在DELETE语句中指定目标表的标识符。指定别名后，必须使用别名代替语句中的实际表。</p>
<p><strong>例子</strong></p>
<p>创建一个示例表，插入几行，然后删除插入的行之一。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="02395bd" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text,  PRIMARY KEY (k1, k2));
INSERT INTO sample VALUES (1, 2.0, 3, &#39;a&#39;), (2, 3.0, 4,  &#39;b&#39;), (3, 4.0, 5, &#39;c&#39;); </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="100c985" class="language- ">
  <code>SELECT * FROM sample ORDER BY k1;
k1 | k2 | v1 | v2
----&#43;----&#43;----&#43;----
   1 | 2 |   3 | a
   2 | 3 |   4 | b
   3 | 4 |   5 | c
(3 rows)</code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="0a041f4" class="language-sql ">
  <code>DELETE FROM sample WHERE k1 = 2 AND k2 = 3;
SELECT * FROM sample ORDER BY k1; </code>
  </pre>
  </div>
<h2 id="do">DO <a href="#do" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DO语句执行匿名代码块，或换句话说，以过程语言执行匿名函数。将代码块视为没有参数的函数的主体，并返回void。它被解析并执行一次。可选LANGUAGE子句可以在代码块之前或之后编写。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1243d00" class="language- ">
  <code>do ::= DO [ LANGUAGE lang_name  ] code</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>code 要执行的过程语言代码。就像在中一样，必须将其指定为字符串文字CREATE FUNCTION。建议使用美元报价文字。</p>
<p>lang_name 编写代码所用的过程语言的名称。如果省略，则默认值为plpgsql。要使用的过程语言必须已经安装在当前数据库中。plpgsql默认情况下已安装，但未安装其他语言。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="41abf94" class="language-sql ">
  <code>DO $$DECLARE r record;
BEGIN
   FOR r IN  SELECT table_schema, table_name FROM information_schema.tables
              WHERE table_type = &#39;VIEW&#39; AND table_schema = &#39;public&#39;
   LOOP
      EXECUTE  &#39;GRANT ALL ON &#39; || quote_ident(r.table_schema) || &#39;.&#39; ||
quote_ident(r.table_name) || &#39; TO webuser&#39;;
      END LOOP;
END$$;</code>
  </pre>
  </div>
<h2 id="drop-aggregate">DROP AGGREGATE <a href="#drop-aggregate" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DROP AGGREGATE语句删除聚合。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f58e0fc" class="language- ">
  <code>drop_aggregate ::= DROP AGGREGATE [ IF EXISTS ]
                     { aggregate_name ( aggregate_signature ) }
                     [ , ... ] [ CASCADE | RESTRICT ]

aggregate_signature ::= * | aggregate_arg [ , ... ]
                              | [ aggregate_arg [ , ... ] ] ORDER  BY
                                  aggregate_arg [ ,  ... ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-drop-aggregate]中每个选项的语义。</p>
<p><strong>例子</strong></p>
<p>基本示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c0fad6c" class="language-sql ">
  <code>CREATE AGGREGATE newcnt(*) (
          sfunc = int8inc,
          stype = int8,
          initcond = &#39;0&#39;,
          parallel = safe
       );
DROP AGGREGATE newcnt(*);</code>
  </pre>
  </div>
<p>IF EXISTS 例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f1df800" class="language-sql ">
  <code>DROP AGGREGATE IF EXISTS newcnt(*);
CREATE AGGREGATE newcnt(*) (
           sfunc = int8inc,
           stype = int8,
           initcond = &#39;0&#39;,
           parallel = safe
        );
DROP AGGREGATE IF EXISTS newcnt(*);  </code>
  </pre>
  </div>
<p>CASCADE和RESTRICT例子。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="0363b49" class="language-sql ">
  <code>CREATE AGGREGATE newcnt(*) (
           sfunc = int8inc,
           stype = int8,
           initcond = &#39;0&#39;,
           parallel = safe
        );
CREATE VIEW cascade_view AS
           SELECT newcnt(*) FROM pg_aggregate;
-- The following should error:
DROP AGGREGATE newcnt(*) RESTRICT;
-- The following should error:
DROP AGGREGATE newcnt(*);
DROP AGGREGATE newcnt(*) CASCADE;</code>
  </pre>
  </div>
<h2 id="drop-cast">DROP CAST <a href="#drop-cast" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP CAST语句删除转换。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="840ced8" class="language- ">
  <code>drop_cast ::= DROP CAST [ IF EXISTS ] ( cast_signature  )
               [ CASCADE | RESTRICT ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-drop-cast]中每个选项的语义。</p>
<p><strong>例子</strong></p>
<p>基本示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1b9539a" class="language-sql ">
  <code>CREATE FUNCTION sql_to_date(integer) RETURNS date AS $$
           SELECT $1::text::date
           $$  LANGUAGE SQL IMMUTABLE STRICT;
CREATE CAST (integer AS date) WITH FUNCTION  sql_to_date(integer) AS ASSIGNMENT;
DROP CAST (integer AS date);  </code>
  </pre>
  </div>
<h2 id="drop-database">DROP DATABASE <a href="#drop-database" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP DATABASE语句从系统中删除数据库及其所有关联对象。这是不可逆转的操作。使用该连接执行语句后，当前打开的数据库连接将失效，然后关闭。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="7372a13" class="language- ">
  <code>drop_database ::= DROP DATABASE [ IF EXISTS ]  database_name </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>DROP DATABASE [ IF EXISTS ] database_name 删除数据库和所有关联的对象。database_name在drop语句完成之后，所有与之相关的对象（例如表）将失效。与删除的数据库的所有连接都将失效，并最终断开连接。 database_name 指定数据库的名称。</p>
<h2 id="drop-domain">DROP DOMAIN <a href="#drop-domain" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DROP DOMAIN语句从数据库中删除域。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="492dd18" class="language- ">
  <code>drop_domain ::= DROP DOMAIN [ IF EXISTS ] name [ , ...  ]
                  [ CASCADE | RESTRICT ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>name 指定现有域的名称。如果指定的域不存在（除非IF EXISTS设置），则会引发错误。如果任何对象都依赖此域（除非CASCADE设置了），则会引发错误。</p>
<p>IF EXISTS 如果域不存在，请不要抛出错误。</p>
<p>CASCADE 使用域数据类型自动删除依赖于域的对象（例如表列），然后自动除去依赖于那些对象的所有其他对象。</p>
<p>RESTRICT 如果对象依赖域，则拒绝删除域（默认）。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="6a4f5ee" class="language-sql ">
  <code>CREATE DOMAIN idx DEFAULT 5 CHECK (VALUE &gt; 0);
DROP DOMAIN idx;  </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5051cad" class="language-sql ">
  <code>CREATE DOMAIN idx DEFAULT 5 CHECK (VALUE &gt; 0);
CREATE TABLE t (k idx primary key);
DROP DOMAIN idx CASCADE;  </code>
  </pre>
  </div>
<h2 id="drop-extension">DROP EXTENSION <a href="#drop-extension" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DROP EXTENSION语句从数据库中删除扩展名。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="94fa772" class="language- ">
  <code>drop_extension ::= DROP EXTENSION [ IF EXISTS ]  extension_name
                     [ , ... ] [ CASCADE | RESTRICT ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>如果扩展名不存在，除非IF     EXISTS使用扩展名，否则将引发错误。然后，发出通知。</li>
<li>RESTRICT 是默认值，如果有任何对象依赖扩展名，它将不会删除该扩展名。</li>
<li>CASCADE 将删除所有依赖于扩展名的可传递对象。</li>
</ul>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="ac22b3f" class="language-sql ">
  <code>DROP EXTENSION IF EXISTS cube;  </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="de40934" class="language-sql ">
  <code>CREATE EXTENSION cube;
CREATE EXTENSION earthdistance;
DROP EXTENSION IF EXISTS cube RESTRICT;  </code>
  </pre>
  </div>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f157f3e" class="language-sql ">
  <code>DROP EXTENSION IF EXISTS cube CASCADE;  </code>
  </pre>
  </div>
<h2 id="drop-function">DROP FUNCTION <a href="#drop-function" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DROP FUNCTION语句从数据库中删除函数。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="fcf8d8d" class="language- ">
  <code>drop_function ::= DROP { FUNCTION | PROCEDURE } [ IF  EXISTS ]
                    { name [ ( [ argtype_decl [ , ... ] ] ) ] }
                    [ , ... ] [ CASCADE | RESTRICT ]

argtype_decl ::= [ argmode ] [ argname ] argtype  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>如果该函数不存在，除非IF     EXISTS使用该函数，否则将引发错误。然后发出通知。</li>
<li>RESTRICT 是默认值，如果有任何对象依赖该函数，它将不会删除该函数。</li>
<li>CASCADE 将会删除所有依赖该功能的对象。</li>
</ul>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="57ca21e" class="language-sql ">
  <code> DROP FUNCTION IF EXISTS inc(i integer), mul(integer,  integer) CASCADE;</code>
  </pre>
  </div>
<h2 id="drop-group">DROP GROUP <a href="#drop-group" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DROP GROUP语句删除角色。DROP GROUP是DROP ROLE的别名</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5bb21e8" class="language-sql ">
  <code>drop_group ::= DROP GROUP [ IF EXISTS ] role_name [ ,  ... ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>参阅DROP_ROLE.</p>
<p><strong>例子</strong></p>
<p>删除一组。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f228c57" class="language-sql ">
  <code>DROP GROUP SysAdmin;</code>
  </pre>
  </div>
<h2 id="drop-operator">DROP OPERATOR <a href="#drop-operator" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DROP OPERATOR语句删除运算符。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="cdfb91b" class="language- ">
  <code>drop_operator ::= DROP OPERATOR [ IF EXISTS ]
                    { operator_name ( operator_signature ) } [ , ... ]
                    [ CASCADE | RESTRICT ]

operator_signature ::= { left_type | NONE } , {  right_type | NONE } </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-drop-operator]中每个选项的语义。</p>
<p><strong>例子</strong></p>
<p>基本示例</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="059f1c2" class="language-sql ">
  <code>CREATE OPERATOR @#@ (
          rightarg = int8,
          procedure = numeric_fac
       );
DROP OPERATOR @#@ (NONE, int8);  </code>
  </pre>
  </div>
<h2 id="drop-operator-class">DROP OPERATOR CLASS <a href="#drop-operator-class" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP OPERATOR CLASS语句删除运算符类。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="3b0daa2" class="language- ">
  <code>drop_operator_class ::= DROP OPERATOR CLASS [ IF EXISTS  ]
                            operator_class_name USING index_method
                            [ CASCADE | RESTRICT ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-drop-operator-class]中每个选项的语义。</p>
<h2 id="drop-owned">DROP OWNED <a href="#drop-owned" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DROP OWNED语句可删除当前数据库中由指定角色之一拥有的所有数据库对象。在当前数据库或共享对象上授予给定角色的任何特权也将被撤销。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="792118d" class="language- ">
  <code>drop_owned ::= DROP OWNED BY role_specification [ , ...  ]
                  [ CASCADE | RESTRICT ]

role_specification ::= role_name | CURRENT_USER |  SESSION_USER  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>CASCADE 自动删除依赖于受影响对象的对象。</p>
<p>RESTRICT 这是默认模式，如果还有其他依赖于删除对象的数据库对象，则会引发错误。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="7bb5ce5" class="language-sql ">
  <code>drop owned by john;</code>
  </pre>
  </div>
<h2 id="drop-policy">DROP POLICY <a href="#drop-policy" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP POLICY语句从表中删除指定的行级安全策略。请注意，如果删除了表的所有策略，并且该表仍然具有ENABLE ROW LEVEL SECURITY，则默认的拒绝所有策略将应用于该表。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="75d0124" class="language- ">
  <code>drop_policy ::= DROP POLICY [ IF EXISTS ] name ON  table_name
                  [ CASCADE | RESTRICT ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>name 是要删除的策略的名称。</li>
<li>table_name 是该策略所在的表的名称。</li>
<li>CASCADE/ RESTRICT没有任何作用，因为表策略没有任何依赖关系。</li>
</ul>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9553f26" class="language-sql ">
  <code>DROP POLICY p1 ON table_foo; </code>
  </pre>
  </div>
<h2 id="drop-procedure">DROP PROCEDURE <a href="#drop-procedure" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用DROP PROCEDURE语句从数据库中删除存储过程。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c7273c3" class="language- ">
  <code>drop_procedure ::= DROP PROCEDURE [ IF EXISTS ]
                     { name [ ( [ argtype_decl [ , ... ] ] ) ] }
                     [ , ... ] [ CASCADE | RESTRICT ]

argtype_decl ::= [ argmode ] [ argname ] argtype</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<ul>
<li>如果该过程不存在，除非IF     EXISTS使用该过程，否则将引发错误。然后发出通知。</li>
<li>RESTRICT 是默认值，如果有任何对象依赖该过程，它将不会删除该过程。</li>
<li>CASCADE 会删除所有依赖该过程的可传递对象。</li>
</ul>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="025a91a" class="language-sql ">
  <code>DROP PROCEDURE IF EXISTS transfer(integer, integer, dec) CASCADE;</code>
  </pre>
  </div>
<h2 id="drop-role">DROP ROLE <a href="#drop-role" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP ROLE语句删除指定的角色。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="3cce0e2" class="language- ">
  <code>drop_role ::= DROP ROLE [ IF EXISTS ] role_name [ , ... ]</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>role_name 是要删除的角色的名称。 要放弃超级用户角色，您必须自己是超级用户。要删除非超级用户角色，您必须具有CREATEROLE特权。</p>
<p>删除角色之前，必须删除其拥有的所有对象（或重新分配其所有权），并撤消已授予该角色在其他对象上的所有特权。REASSIGN OWNED和DROP OWNED命令可被用于此目的。</p>
<p>但是，没有必要删除涉及该角色的角色成员资格。DROP ROLE自动撤销其他角色中目标角色的所有成员身份，以及目标角色中其他角色的成员资格。其他角色不会丢失或受影响。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e203fc8" class="language-sql ">
  <code>DROP ROLE John;  </code>
  </pre>
  </div>
<h2 id="drop-rule">DROP RULE <a href="#drop-rule" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP RULE语句删除规则。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d150776" class="language- ">
  <code>drop_rule ::= DROP RULE [ IF EXISTS ] rule_name ON  table_name
                [ CASCADE | RESTRICT ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>请参见[PostgreSQL docs] [postgresql-docs-drop-rule]中每个选项的语义。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="05bac78" class="language-sql ">
  <code>CREATE TABLE t1(a int4, b int4);
CREATE TABLE t2(a int4, b int4);
CREATE RULE t1_to_t2 AS ON INSERT TO t1 DO INSTEAD
             INSERT INTO t2 VALUES (new.a, new.b);
DROP RULE t1_to_t2 ON t1;  </code>
  </pre>
  </div>
<h2 id="drop-sequence">DROP SEQUENCE <a href="#drop-sequence" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP SEQUENCE语句删除当前模式中的序列。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="756e5ea" class="language- ">
  <code>drop_sequence ::= DROP SEQUENCE [ IF EXISTS ]  sequence_name
                    [ CASCADE | RESTRICT ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>sequence_name 指定序列的名称。</p>
<ul>
<li>如果除非IF     EXISTS指定，否则在当前模式中不存在具有该名称的序列，则会引发错误。</li>
<li>如果任何对象都依赖于此序列，则将引发错误，除非CASCADE指定了该选项。 CASCADE 还删除所有依赖于此顺序的对象（例如DEFAULT，表列中的值）。 RESTRICT 如果有任何对象依赖此序列，请不要删除它。即使未指定，这也是默认行为。</li>
</ul>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="03af2eb" class="language-sql ">
  <code>CREATE TABLE t(k SERIAL, v INT);
DROP SEQUENCE t_k_seq;
DROP SEQUENCE t_k_seq CASCADE;  </code>
  </pre>
  </div>
<h2 id="drop-table">DROP TABLE <a href="#drop-table" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP TABLE语句从数据库中删除一个或多个表（及其所有数据）。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f60c170" class="language- ">
  <code>drop_table  ::= DROP TABLE [ IF EXISTS ] table_name [ , ... ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>if_exists在正常操作下，如果表不存在，则会引发错误。添加IF EXISTS将静默忽略指定的任何不存在的表。</p>
<p>table_name指定要删除的表的名称。与该表关联的对象（例如，准备好的语句）在该DROP TABLE语句完成之后最终将失效。</p>
<h2 id="drop-trigger">DROP TRIGGER <a href="#drop-trigger" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP TRIGGER语句从数据库中删除触发器。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5c72ec7" class="language- ">
  <code>drop_trigger  ::= DROP TRIGGER [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>RESTRICT 是默认值，如果有任何对象依赖触发器，它将引发错误。</p>
<p>CASCADE 将删除所有（暂时地）取决于触发器的对象。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9fe54dc" class="language-sql ">
  <code>DROP  TRIGGER update_moddatetime ON posts;</code>
  </pre>
  </div>
<h2 id="drop-type">DROP TYPE <a href="#drop-type" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP TYPE语句从数据库中删除用户定义的类型。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="185be86" class="language- ">
  <code>drop_type  ::= DROP TYPE [ IF EXISTS ] type_name [ , ... ] [ CASCADE | RESTRICT ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>type_name 指定要删除的用户定义类型的名称。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="65a7942" class="language-sql ">
  <code>CREATE  TYPE feature_struct AS (id INTEGER, name TEXT);

DROP  TYPE feature_struct;  </code>
  </pre>
  </div>
<p>IF EXISTS 示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e65f154" class="language-sql ">
  <code>DROP  TYPE IF EXISTS feature_shell;</code>
  </pre>
  </div>
<p>CASCADE 示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="aeea6be" class="language-sql ">
  <code>CREATE  TYPE feature_enum AS ENUM (&#39;one&#39;, &#39;two&#39;, &#39;three&#39;);
CREATE TABLE feature_tab_enum (feature_col feature_enum);
DROP TYPE feature_tab_enum  CASCADE;</code>
  </pre>
  </div>
<p>RESTRICT 示例。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="615b36b" class="language-sql ">
  <code>CREATE  TYPE feature_range AS RANGE (subtype=INTEGER);
CREATE TABLE feature_tab_range  (feature_col feature_range); -- The following should error: DROP TYPE  feature_range RESTRICT; DROP TABLE feature_tab_range;
DROP TYPE feature_range  RESTRICT;  </code>
  </pre>
  </div>
<h2 id="drop-user">DROP USER <a href="#drop-user" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该DROP USER语句删除用户或角色。DROP USER是 DROP ROLE 的别名。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="79ea38b" class="language- ">
  <code>drop_user  ::= DROP USER [ IF EXISTS ] role_name [ , ... ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>参看DROP_ROLE</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="58bb66d" class="language-sql ">
  <code>DROP USER John;</code>
  </pre>
  </div>
<h2 id="end">END <a href="#end" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该END语句提交当前事务。事务所做的所有更改对其他人都可见，并且如果崩溃发生，保证可以持久。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1927689" class="language- ">
  <code>end  ::= END [ TRANSACTION | WORK ]</code>
  </pre>
  </div>
<h2 id="execute">EXECUTE <a href="#execute" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该EXECUTE语句执行先前准备的语句。这种分离是一种性能优化，因为准备好的语句将使用不同的值执行多次，而语法和语义分析以及重写在PREPARE处理期间仅执行一次。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="97c40e0" class="language- ">
  <code>execute_statement  ::= EXECUTE name [ ( expression [ , ... ] ) ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>name指定要执行的准备好的语句的名称。</p>
<p>expression指定表达式。中的每个表达式EXECUTE必须与中的对应数据类型匹配PREPARE。</p>
<p><strong>例子</strong></p>
<p>创建一个sample表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="73b294c" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text, PRIMARY KEY (k1, k2));</code>
  </pre>
  </div>
<p>执行一次简单插入。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="85c4788" class="language-sql ">
  <code>PREPARE  ins (bigint, double precision, int, text) AS INSERT INTO sample(k1, k2, v1,  v2) VALUES ($1, $2, $3, $4);  </code>
  </pre>
  </div>
<p>执行两次插入。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="e97865a" class="language-sql ">
  <code>EXECUTE  ins(1, 2.0, 3, &#39;a&#39;); EXECUTE ins(2, 3.0, 4, &#39;b&#39;);</code>
  </pre>
  </div>
<p>检查结果。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="92fea33" class="language-sql ">
  <code>SELECT * FROM sample ORDER BY k1;</code>
  </pre>
  </div>
<h2 id="explain">EXPLAIN <a href="#explain" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该EXPLAIN语句显示一条语句的执行计划。如果使用该ANALYZE选项，则将执行该语句，而不仅仅是计划的语句。在这种情况下，执行信息（而不仅仅是计划者的估计）将添加到EXPLAIN结果中。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a14151b" class="language- ">
  <code>explain  ::= EXPLAIN [ [ ANALYZE ] [ VERBOSE ] | ( option [ , ... ] ) ] statement

option  ::= ANALYZE [ boolean ] | VERBOSE [ boolean ] | COSTS [ boolean ] | BUFFERS [  boolean ] | TIMING [ boolean ] | SUMMARY [ boolean ] | FORMAT { TEXT | XML |  JSON | YAML }  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>ANALYZE执行该语句并显示实际运行时间和其他统计信息。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d811f16" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text, PRIMARY KEY (k1,  k2));
INSERT INTO sample(k1, k2, v1, v2) VALUES (1, 2.0, 3, &#39;a&#39;), (2, 3.0, 4,  &#39;b&#39;), (3, 4.0, 5, &#39;c&#39;); EXPLAIN SELECT * FROM sample WHERE k1 = 1; QUERY PLAN

Foreign  Scan on sample (cost=0.00..112.50 rows=1000 width=44) (1 row)  </code>
  </pre>
  </div>
<h2 id="grant">GRANT <a href="#grant" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该GRANT语句授予对数据库对象的访问特权，并分配角色成员身份。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="333c0eb" class="language- ">
  <code>grant_table  ::= GRANT { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES |  TRIGGER } [ , ... ] | ALL [ PRIVILEGES ] } ON { [ TABLE ] table_name [ , ...  ] | ALL TABLES IN SCHEMA schema_name [ , ... ] } TO grant_role_spec [ , ... ]  [ WITH GRANT OPTION ]

grant_table_col  ::= GRANT { { SELECT | INSERT | UPDATE | REFERENCES } ( column_names ) [  ,(column_names ... ] | ALL [ PRIVILEGES ] ( column_names ) } ON { [ TABLE ]  table_name [ , ... ] } TO grant_role_spec [ , ... ] [ WITH GRANT OPTION ]

grant_seq  ::= GRANT { { USAGE | SELECT | UPDATE } [ , ... ] | ALL [ PRIVILEGES ] } ON {  SEQUENCE sequence_name [ , ... ] | ALL SEQUENCES IN SCHEMA schema_name [ ,  sequence_name [ ... ] ] } TO grant_role_spec [ , ... ] [ WITH GRANT OPTION ]

grant_db  ::= GRANT { { CREATE | CONNECT | TEMPORARY | TEMP } [ , ... ] | ALL [  PRIVILEGES ] } ON DATABASE database_name [ , ... ] TO grant_role_spec [ , ...  ] [ WITH GRANT OPTION ]

grant_domain  ::= GRANT { USAGE | ALL [ PRIVILEGES ] } ON DOMAIN domain_name [ , ... ] TO  grant_role_spec [ , ... ] [ WITH GRANT OPTION ]

grant_schema  ::= GRANT { { CREATE | USAGE } [ , ... ] | ALL [ PRIVILEGES ] } ON SCHEMA  schema_name [ , ... ] TO grant_role_spec [ , ... ] [ WITH GRANT OPTION ]

grant_type  ::= GRANT { USAGE | ALL [ PRIVILEGES ] } ON TYPE type_name [ , ... ] TO  grant_role_spec [ , ... ] [ WITH GRANT OPTION ]

grant_role  ::= GRANT role_name [ , ... ] TO role_name [ , ... ] [ WITH ADMIN OPTION ]  

grant_role_spec  ::= [ GROUP ] role_name | PUBLIC | CURRENT_USER | SESSION_USER  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>GRANT 可用于分配数据库对象以及角色成员的特权。</p>
<p>GRANT 在数据库对象上</p>
<p>此GRANT命令的变体用于将数据库对象的特权分配给一个或多个角色。如果使用关键字PUBLIC代替role_name，则表示将特权授予所有角色，包括以后可能创建的角色。</p>
<p>如果WITH GRANT OPTION指定，则特权的接收者可以依次将其授予其他人。没有授予选项，接收者将无法做到这一点。授予选项不能授予PUBLIC。</p>
<p>无需授予对象所有者（通常是创建对象的用户）特权，因为默认情况下所有者具有所有特权。（不过，所有者可以出于安全考虑选择撤销自己的某些特权。）</p>
<p>·   + SELECT</p>
<p>这允许从指定表，视图或序列的任何或指定列中进行SELECT。它还允许使用COPY TO。在UPDATE或DELETE中引用现有列值时，也需要此特权。</p>
<p>·   + INSERT</p>
<p>这允许将新行插入到指定表中。如果列出了特定的列，则只能在INSERT命令中将这些列分配给其他列（因此其他列将接收默认值）。还允许COPY FROM。</p>
<p>·   + UPDATE</p>
<p>这允许更新指定表的任何列或列出的特定列。</p>
<p>·   + DELETE</p>
<p>这允许从指定表中删除一行。</p>
<p>·   + TRUNCATE</p>
<p>这允许在指定的表上执行TRUNCATE。</p>
<p>·   + REFERENCES</p>
<p>这允许创建引用指定表或表的指定列的外键约束。</p>
<p>·   + TRIGGER</p>
<p>这允许在指定的表上创建触发器。</p>
<p>·   + CREATE</p>
<p>对于数据库，这允许在数据库中创建新的架构。</p>
<p>对于模式，这允许在模式内创建新对象。要重命名现有对象，您必须拥有该对象，并对包含的架构具有此特权。</p>
<p>·   + CONNECT</p>
<p>这使用户可以连接到指定的数据库。连接启动时检查此特权。</p>
<p>·   + TEMPORARY/TEMP</p>
<p>这允许在使用指定的数据库时创建临时表。</p>
<p>·   + EXECUTE</p>
<p>允许使用指定的功能或过程，以及使用在该功能之上实现的任何运算符。</p>
<p>·   + USAGE</p>
<p>对于模式，这允许访问指定模式中包含的对象（假设还满足对象自己的特权要求）。从本质上讲，这允许被授予者“查询”架构中的对象。</p>
<p>对于序列，此特权允许使用currval()和nextval()函数。</p>
<p>对于类型和域，此特权允许在创建表，函数和其他架构对象时使用类型或域。</p>
<p>·   + ALL PRIVILEGES</p>
<p>一次授予所有特权。</p>
<p>GRANT 在角色上的这一变体GRANT用于将一个角色的成员资格授予一个或多个其他角色。如果WITH ADMIN OPTION指定，则成员可以依次将角色的成员身份授予其他人，也可以撤消该角色的成员身份。</p>
<p><strong>例子</strong></p>
<p>向表“ stores”上的所有用户授予SELECT特权。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="0d2bd08" class="language-sql ">
  <code>GRANT  SELECT ON stores TO PUBLIC;</code>
  </pre>
  </div>
<p>将用户John添加到SysAdmins组。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8939092" class="language-sql ">
  <code>GRANT SysAdmins TO John;</code>
  </pre>
  </div>
<h2 id="insert">INSERT <a href="#insert" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该INSERT语句将一或多个行添加到指定的表。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c29db5c" class="language- ">
  <code>insert  ::= [ WITH [ RECURSIVE ] with_query [ , ... ] ] INSERT INTO table_name [ AS  alias ] [ ( column_names ) ]
{ DEFAULT VALUES | VALUES ( column_values ) [ ,(column_values ... ] |  subquery }
[ ON CONFLICT [ conflict_target ] conflict_action ]
[ returning_clause ]

returning_clause  ::= RETURNING { * | { output_expression [ [ AS ] output_name ] } [ , ... ] }

column_values  ::= { expression | DEFAULT } [ , ... ]

conflict_target  ::= ( { column_name | expression } [ , ... ] ) [ WHERE condition ] | ON  CONSTRAINT constraint_name

conflict_action  ::= DO NOTHING | DO UPDATE SET update_item [ , ... ] [ WHERE condition ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>table_name指定表的名称。如果指定的表不存在，则会引发错误。</p>
<p>column_names指定以逗号分隔的列名称列表。如果指定的列不存在，则会引发错误。每个主键列都必须具有非null值。</p>
<p>VALUES clause</p>
<p>·   每个值列表必须与列列表具有相同的长度。</p>
<p>·   每个值必须可转换为其相应的（按位置）列类型。</p>
<p>·   每个值文字可以是一个表达式。</p>
<p>ON CONFLICT clause</p>
<p>·   目标表必须至少具有一个具有唯一索引或唯一约束的列（列表）。我们将其称为唯一密钥。VALUES的参数是一种关系，必须至少包含目标表的唯一键之一。此唯一键的某些值可能是新值，而其他值可能已存在于目标表中。</p>
<p>·   INSERT ON CONFLICT的基本目的是简单地插入具有唯一键的新值的行，并使用唯一键的现有值更新行，以将其余指定列的值设置为VALUES关系中的值。这样，最终效果是插入或更新。因此，“ INSERT ON CONFLICT”变体通常被通俗地称为“ upsert”。</p>
<p><strong>例子</strong></p>
<p>基本示例</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a97cce1" class="language-sql ">
  <code>CREATE  TABLE sample(k1 int, k2 int, v1 int, v2 text, PRIMARY KEY (k1, k2));

INSERT  INTO sample VALUES (1, 2.0, 3, &#39;a&#39;), (2, 3.0, 4, &#39;b&#39;), (3, 4.0, 5, &#39;c&#39;);

SELECT  * FROM sample ORDER BY k1;</code>
  </pre>
  </div>
<p>“ upsert”示例。重新创建并重新填充示例表。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="933a4be" class="language-sql ">
  <code>DROP  TABLE IF EXISTS sample CASCADE;

CREATE  TABLE sample( id int CONSTRAINT sample_id_pk PRIMARY KEY, c1 text CONSTRAINT  sample_c1_NN NOT NULL, c2 text CONSTRAINT sample_c2_NN NOT NULL);

INSERT  INTO sample(id, c1, c2) VALUES (1, &#39;cat&#39; , &#39;sparrow&#39;), (2, &#39;dog&#39; ,  &#39;blackbird&#39;), (3, &#39;monkey&#39; , &#39;thrush&#39;);

SELECT  id, c1, c2 FROM sample ORDER BY id;

INSERT INTO sample(id, c1, c2) VALUES (3,  &#39;horse&#39; , &#39;pigeon&#39;), (4, &#39;cow&#39; , &#39;robin&#39;) ON CONFLICT DO NOTHING; </code>
  </pre>
  </div>
<h2 id="lock">LOCK <a href="#lock" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该LOCK语句锁定表。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="97337c8" class="language- ">
  <code>lock_table  ::= LOCK [ TABLE ] { { [ ONLY ] name [ * ] } [ , ... ] } [ IN lockmode MODE ]  [ NOWAIT ]  lockmode  ::= ACCESS SHARE| ROW SHARE | ROW EXCLUSIVE | SHARE UPDATE EXCLUSIVE | SHARE  | SHARE ROW EXCLUSIVE | EXCLUSIVE | ACCESS EXCLUSIVE  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>name指定要锁定的现有表。</p>
<p>lockmode目前仅支持 ACCESS SHARE 锁模式。</p>
<p>下面列出的所有其他模式正在开发中。</p>
<p>ACCESS SHARE | ROW SHARE | ROW EXCLUSIVE | SHARE UPDATE EXCLUSIVE | SHARE | SHARE ROW EXCLUSIVE | EXCLUSIVE | ACCESS EXCLUSIVE</p>
<h2 id="prepare">PREPARE <a href="#prepare" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该PREPARE语句创建目标语句句柄。用来分析和重写（但不执行）。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="9dd7ffb" class="language- ">
  <code>prepare_statement ::= PREPARE name [ ( data_type [ ,  ... ] ) ] AS statement</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>PREPARE可能（应该）包含$1将由中的表达式列表提供的参数（例如）EXECUTE。</p>
<p>数据类型列表PREPARE表示语句中使用的参数的类型。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="a58b954" class="language-sql ">
  <code>CREATE  TABLE sample(k1 int, k2 int, v1 int, v2 text, PRIMARY KEY (k1, k2));

PREPARE  ins (bigint, double precision, int, text) AS INSERT INTO sample(k1, k2, v1,  v2) VALUES ($1, $2, $3, $4);

EXECUTE  ins(1, 2.0, 3, &#39;a&#39;);

EXECUTE  ins(2, 3.0, 4, &#39;b&#39;);

SELECT  * FROM sample ORDER BY k1;  </code>
  </pre>
  </div>
<h2 id="reassign-owned">REASSIGN OWNED <a href="#reassign-owned" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该REASSIGN OWNED语句可以将数据库对象的所有权由 old_roles改为 new_role。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="3cb43f6" class="language- ">
  <code>reassign_owned  ::= REASSIGN OWNED BY role_specification [ , ... ] TO role_specification

role_specification  ::= role_name | CURRENT_USER | SESSION_USER  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>REASSIGN OWNED通常用于准备删除角色。它要求源角色和目标角色都具有成员身份。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="3e220e6" class="language-sql ">
  <code>reassign  owned by john to memfire;</code>
  </pre>
  </div>
<h2 id="reset">RESET <a href="#reset" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该RESET语句将运行时参数的值恢复为默认值。RESET映射到SET configuration_parameter TO DEFAULT。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="62bab47" class="language- ">
  <code>reset_stmt  ::= RESET { name | ALL }  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p><strong>configuration_parameter</strong>指定可变的运行时参数的名称。</p>
<h2 id="revoke">REVOKE <a href="#revoke" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该REVOKE语句删除一个或多个角色的访问权限。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1713d7e" class="language- ">
  <code>revoke_table  ::= REVOKE [ GRANT OPTION FOR ] { { SELECT | INSERT | UPDATE | DELETE |  TRUNCATE | REFERENCES | TRIGGER } [ , ... ] | ALL [ PRIVILEGES ] } ON { [  TABLE ] table_name [ , ... ] | ALL TABLES IN SCHEMA schema_name [ , ... ] }  FROM { [ GROUP ] role_name | PUBLIC } [ , ... ] [ CASCADE | RESTRICT ]

revoke_table_col  ::= REVOKE [ GRANT OPTION FOR ] { { SELECT | INSERT | UPDATE | REFERENCES } (  column_names ) [ ,(column_names ... ] | ALL [ PRIVILEGES ] ( column_names ) }  ON [ TABLE ] table_name [ , ... ] FROM { [ GROUP ] role_name | PUBLIC } [ ,  ... ] [ CASCADE | RESTRICT ]

revoke_seq  ::= REVOKE [ GRANT OPTION FOR ] { { USAGE | SELECT | UPDATE } [ , ... ] | ALL  [ PRIVILEGES ] } ON { SEQUENCE sequence_name [ , ... ] | ALL SEQUENCES IN  SCHEMA schema_name [ , ... ] } FROM { [ GROUP ] role_name | PUBLIC } [ , ...  ] [ CASCADE | RESTRICT ]

revoke_db  ::= REVOKE [ GRANT OPTION FOR ] { { CREATE | CONNECT | TEMPORARY | TEMP } [ ,  ... ] | ALL [ PRIVILEGES ] } ON DATABASE database_name [ , ... ] FROM { [  GROUP ] role_name | PUBLIC } [ , ... ] [ CASCADE | RESTRICT ]

revoke_domain  ::= REVOKE [ GRANT OPTION FOR ] { USAGE | ALL [ PRIVILEGES ] } ON DOMAIN  domain_name [ , ... ] FROM { [ GROUP ] role_name | PUBLIC } [ , ... ] [  CASCADE | RESTRICT ]

revoke_schema  ::= REVOKE [ GRANT OPTION FOR ] { { CREATE | USAGE } [ , ... ] | ALL [  PRIVILEGES ] } ON SCHEMA schema_name [ , ... ] FROM { [ GROUP ] role_name |  PUBLIC } [ , ... ] [ CASCADE | RESTRICT ]

revoke_type  ::= REVOKE [ GRANT OPTION FOR ] { USAGE | ALL [ PRIVILEGES ] } ON TYPE  type_name [ , ... ] FROM { [ GROUP ] role_name | PUBLIC } [ , ... ] [ CASCADE  | RESTRICT ]

revoke_role  ::= REVOKE [ ADMIN OPTION FOR ] role_name [ , ... ] FROM role_name [ , ... ]  [ CASCADE | RESTRICT ]</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>任何角色都有分配给它的所有特权的总和。所以，如果REVOKE是用于撤消SELECT从PUBLIC，那么它并不意味着所有角色都失去SELECT特权。如果角色已SELECT直接授予或通过组继承，则它可以继续保留SELECT特权。</p>
<p>如果GRANT OPTION FOR指定，则仅撤销特权的授予选项，而不撤销特权本身。否则，特权和授予选项都将被吊销。</p>
<p>同样，在撤消角色时（如果ADMIN OPTION FOR已指定），则仅撤消特权的admin选项。</p>
<p>如果一个用户拥有带有授予选项的特权，并且已经将其授予其他用户，则如果CASCADE指定了特权，则从第一个用户撤消该特权也会从相关用户撤消它。否则，REVOKE将失败。</p>
<p>撤消表的特权时，表的每一列也会自动撤消相应的列特权（如果有）。另一方面，如果已向角色授予表特权，则从各个列中撤消相同特权将无效。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="48e2b14" class="language-sql ">
  <code>REVOKE  SELECT ON stores FROM PUBLIC; REVOKE SysAdmins FROM John;</code>
  </pre>
  </div>
<h2 id="rollback">ROLLBACK <a href="#rollback" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该ROLLBACK语句回滚当前事务。此事务中包含的所有更改将被丢弃。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d69369c" class="language- ">
  <code>rollback  ::= ROLLBACK [ TRANSACTION | WORK ] </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>WORK可选</p>
<p>TRANSACTION可选</p>
<h2 id="select">SELECT <a href="#select" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该SELECT语句从表中检索满足给定条件的指定列的行。它指定要检索的列，表的名称以及每个选定行必须满足的条件。</p>
<p>无论您在何处使用子查询，都可以使用相同的语法规则（例如在INSERTstatement中）。某些语法点（例如，WHERE子句谓词或诸如的函数的实际参数）sqrt()仅允许标量子查询。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="97a07bc" class="language- ">
  <code>select  ::= [ WITH [ RECURSIVE ] { with_query [ , ... ] } ] SELECT [ ALL | DISTINCT [  ON { ( expression [ , ... ] ) } ] ] [ * | { { expression | fn_over_window } [  [ AS ] name ] } [ , ... ] ] [ FROM { from_item [ , ... ] } ]
[ WHERE condition ]
[ GROUP BY { grouping_element [ , ... ] } ]
[ HAVING { condition [ , ... ] } ]
[ WINDOW { { name AS window_definition } [ , ... ] } ]
[ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ] [ ORDER BY {  order_expr [ , ... ] } ]
[ LIMIT [ integer | ALL ] ]
[ OFFSET integer [ ROW | ROWS ] ]

fn_over_window  ::= fn_invocation [ FILTER ( WHERE { boolean_expression [ , ... ] } ) ] OVER  { window_definition | name }

order_expr  ::= expression [ ASC | DESC | USING operator_name ] [ NULLS { FIRST | LAST }  ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>如果指定的table_name不存在，则会引发错误。</p>
<p>*代表所有列。</p>
<p>尽管where子句允许使用多种运算符，但是where子句中使用的确切条件具有重要的性能考虑因素（尤其是对于大型数据集）。</p>
<p>condition指定一个计算结果为布尔值的表达式。</p>
<p>有关详细信息from_item，grouping_element以及with_query看到SELECT 在PostgreSQL文档中。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="601c65b" class="language-sql ">
  <code>CREATE  TABLE sample1(k1 bigint, k2 float, v text, PRIMARY KEY (k1, k2));

CREATE  TABLE sample2(k1 bigint, k2 float, v text, PRIMARY KEY (k1, k2));

INSERT  INTO sampleINSERT INTO sample2(k1, k2, v) VALUES (1, 2.5, &#39;foo&#39;), (1, 4.5,  &#39;bar&#39;);

INSERT INTO sample2(k1, k2, v) VALUES (1,  2.5, &#39;foo&#39;), (1, 4.5, &#39;bar&#39;);

SELECT  a.k1, a.k2, a.v as av, b.v as bv FROM sample1 a LEFT JOIN sample2 b ON (a.k1  = b.k1 and a.k2 = b.k2) WHERE a.k1 = 1 AND a.k2 IN (2.5, 3.5) ORDER BY a.k2  DESC;  </code>
  </pre>
  </div>
<h2 id="set">SET <a href="#set" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该SET语句更新运行时控制参数。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="d2bf766" class="language- ">
  <code>set  ::= SET [ SESSION | LOCAL ] { configuration_parameter { TO | = } { value |  DEFAULT } | TIME ZONE { timezone | LOCAL | DEFAULT } }  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>尽管可以设置，显示和重置参数的值，但MemFire尚不支持这些参数的效果。目前将使用默认设置和行为。</p>
<p>SESSION指定该命令仅影响当前会话。</p>
<p>LOCAL指定该命令仅影响当前事务。COMMIT或之后ROLLBACK，会话级设置再次生效。</p>
<p>configuration_parameter指定可变的运行时参数的名称。</p>
<p>value指定参数的新值。</p>
<h2 id="set-constraints">SET CONSTRAINTS <a href="#set-constraints" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该SET CONSTRAINTS语句设置当前事务中约束检查的时间。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="1bd9f68" class="language- ">
  <code>set_constraints  ::= SET CONSTRAINTS { ALL | name [ , ... ] } { DEFERRED | IMMEDIATE }</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>SET CONSTRAINTS语句中的属性符合SQL标准中定义的行为，但不适用于NOT NULL和CHECK约束。</p>
<p>SET CONSTRAINTS { ALL | *name [ , &hellip; ] } { DEFERRED | IMMEDIATE }</p>
<p>ALL更改所有可延迟约束的模式。</p>
<p>name指定约束名称之一或列表。</p>
<p>DEFERRED将约束设置为在事务提交之前不检查约束。</p>
<p>除非标记，否则立即检查唯一性和排除约束DEFERRABLE。</p>
<p>IMMEDIATE设置约束以追溯生效。</p>
<h2 id="set-role">SET ROLE <a href="#set-role" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该SET ROLE语句将当前会话的当前用户设置为指定用户。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="6525a0a" class="language- ">
  <code>set_role  ::= SET [ SESSION | LOCAL ] ROLE { role_name | NONE } reset_role ::= RESET  ROLE</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>指定role_name的角色必须是当前会话用户所属的角色。超级用户可以设置为任何角色。一旦将角色设置为role_name，任何其他SQL命令将使用该角色可用的特权。</p>
<p>将角色重置回当前用户，RESET ROLE或SET ROLE NONE可以使用。</p>
<p><strong>例子</strong></p>
<p>换上新角色约翰</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c81ae79" class="language-sql ">
  <code>select  session_user, current_user;

set  role john;

select  session_user, current_user; </code>
  </pre>
  </div>
<h2 id="set-session-authorization">SET SESSION AUTHORIZATION <a href="#set-session-authorization" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该SET SESSION AUTHORIZATION语句将当前会话的当前用户和会话用户设置为指定用户。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="c1586ad" class="language- ">
  <code>set_session_authorization  ::= SET [ SESSION | LOCAL ] SESSION AUTHORIZATION { role_name | DEFAULT }

reset_session_authorization  ::= RESET SESSION AUTHORIZATION  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>会话用户只能由超级用户更改。一旦role_name将会话用户设置为，任何其他SQL命令将使用该角色可用的特权。</p>
<p>可以将会话用户重置为当前经过身份验证的用户，RESET SESSION AUTHORIZATION或者SET SESSION AUTHORIZATION DEFAULT可以使用。</p>
<p><strong>例子</strong></p>
<p>将会话用户设置为John。</p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="8eb5289" class="language-sql ">
  <code>Set session user to John.

select  session_user, current_user;

SET  select session_user, current_user; </code>
  </pre>
  </div>
<h2 id="set-transaction">SET TRANSACTION <a href="#set-transaction" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该SET TRANSACTION语句设置当前事务隔离级别。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="b3962b1" class="language- ">
  <code>set  ::= SET [ SESSION | LOCAL ] { configuration_parameter { TO | = } { value |  DEFAULT } | TIME ZONE { timezone | LOCAL | DEFAULT } }  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p><em><strong>*transaction_mode*</strong></em></p>
<p>将事务处理模式设置为以下之一。</p>
<p>·   ISOLATION LEVEL 条款</p>
<p>·   存取方式</p>
<p>·   DEFERRABLE 模式</p>
<p><strong>ISOLATION LEVEL clause</strong></p>
<p>+ SERIALIZABLE</p>
<p>+ REPEATABLE READ</p>
<p>+ READ COMMITTED</p>
<p>+ READ UNCOMMITTED</p>
<p><strong>READ WRITE</strong> <strong>模式</strong></p>
<p>默认该模式</p>
<p><strong>READ ONLY</strong> <strong>模式</strong></p>
<p>该READ ONLY模式不会阻止所有写入磁盘。</p>
<p>当事务为时READ ONLY，以下SQL语句：</p>
<p>+ 如果他们要写入的表不是临时表，则不允许使用。</p>
<p>+ INSERT</p>
<p>+ UPDATE</p>
<p>+ DELETE</p>
<p>+ COPY FROM</p>
<p>+ 一律禁止</p>
<p>+ COMMENT</p>
<p>+ GRANT</p>
<p>+ REVOKE</p>
<p>+ TRUNCATE</p>
<p>+ 当将要执行的语句是上述之一时，不允许使用</p>
<p>+ EXECUTE</p>
<p>+ EXPLAIN ANALYZE</p>
<p><em><strong>*DEFERRABLE mode*</strong></em></p>
<p>仅当同时选择SERIALIZABLE和READ ONLY模式时，才用于延迟事务。如果使用该事务，则该事务在首次获取其快照时可能会阻塞，此后它可以在没有SERIALIZABLE事务的正常开销的情况下运行，并且没有任何导致序列化失败或被序列化失败取消的风险。</p>
<p>该DEFERRABLE模式对于长时间运行的报告或备份可能很有用。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="5605a6f" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text,  PRIMARY KEY (k1, k2));
BEGIN TRANSACTION;
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
INSERT INTO sample(k1, k2, v1, v2) VALUES (1, 2.0, 3,  &#39;a&#39;), (1, 3.0, 4, &#39;b&#39;);
COMMIT TRANSACTION; -- run in first shell.  </code>
  </pre>
  </div>
<h2 id="show">SHOW <a href="#show" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该SHOW语句显示运行时参数的值。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="f9676e5" class="language- ">
  <code>show_stmt  ::= SHOW { name | ALL } </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>configuration_parameter指定要显示的参数的名称。</p>
<p>ALL显示所有配置参数的值以及说明。</p>
<h2 id="show-transaction">SHOW TRANSACTION <a href="#show-transaction" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该SHOW TRANSACTION语句显示当前的事务隔离级别。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="2f15b30" class="language- ">
  <code>show_transaction  ::= SHOW TRANSACTION ISOLATION LEVEL</code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>在TRANSACTION ISOLATION LEVEL返回的要么是SERIALIZABLE或REPEATABLE READS。在MemFire中，PostgreSQL 的READ COMMITTED和READ UNCOMMITTED映射到REPEATABLE READS。</p>
<h2 id="truncate">TRUNCATE <a href="#truncate" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用该TRUNCATE语句清除表中的所有行。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="aece2db" class="language- ">
  <code>truncate  ::= TRUNCATE [ TABLE ] { { [ ONLY ] name [ * ] } [ , ... ] }  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>name指定要截断的表的名称。</p>
<p>TRUNCATE获取ACCESS EXCLUSIVE锁。在ACCESS EXCLUSIVE 锁 还没有完全支持。</p>
<p>TRUNCATE 外部表不支持。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="675740b" class="language-sql ">
  <code>CREATE TABLE sample(k1 int, k2 int, v1 int, v2 text,  PRIMARY KEY (k1, k2));
INSERT INTO sample VALUES (1, 2.0, 3, &#39;a&#39;), (2, 3.0, 4,  &#39;b&#39;), (3, 4.0, 5, &#39;c&#39;);
SELECT * FROM sample ORDER BY k1;
TRUNCATE sample; SELECT * FROM sample;  </code>
  </pre>
  </div>
<h2 id="update">UPDATE <a href="#update" class="anchor" aria-hidden="true"><i class="material-icons align-middle">link</i></a></h2><p><strong>概要</strong></p>
<p>使用UPDATE语句修改满足某些条件的所有行中指定列的值，并且当WHERE子句中未提供条件时，将更新所有行。UPDATE输出要更新的行数。</p>
<p><strong>语法</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="76c2f84" class="language- ">
  <code>update  ::= [ WITH [ RECURSIVE ] with_query [ , ... ] ] UPDATE [ ONLY ] table_name [  * ] [ [ AS ] alias ] SET update_item [ , ... ] [ WHERE condition | WHERE  CURRENT OF cursor_name ] [ returning_clause ]

returning_clause  ::= RETURNING { * | { output_expression [ [ AS ] output_name ] } [ , ... ] }

update_item  ::= column_name = column_value | ( column_names ) = [ ROW ] ( column_values )  | ( column_names ) = ( query )

column_values  ::= { expression | DEFAULT } [ , ... ]

column_names  ::= column_name [ , ... ]  </code>
  </pre>
  </div>
<p><strong>语义</strong></p>
<p>尚不支持更新包含PRIMARY KEY的索引键一部分的列。</p>
<p>尽管该WHERE子句允许使用多种运算符，但是where子句中使用的确切条件具有重要的性能考虑因素（尤其是对于大型数据集）。为了获得最佳性能，请使用WHERE为PRIMARY KEY或中的所有列提供值的子句INDEX KEY。</p>
<p>with_query指定在UPDATE语句中按名称引用的子查询。</p>
<p>table_name指定要更新的表的名称</p>
<p>alias在UPDATE语句中指定目标表的标识符。指定别名后，必须使用别名代替语句中的实际表。</p>
<p>column_name在表中指定要更新的列。</p>
<p>expression指定要分配给列的值。当表达式引用一列时，该列的旧值用于评估。</p>
<p>output_expression指定要返回的值。当output_expression引用一列时，该列的新值（更新值）用于评估。</p>
<p>subquery指定SELECT子查询语句。其选择的值将分配给指定的列。</p>
<p><strong>例子</strong></p>



  
  
  

  
  
  
  

  

  <div class="prism-codeblock ">
  <pre id="da6578b" class="language-sql ">
  <code>CREATE  TABLE sample(k1 int, k2 int, v1 int, v2 text, PRIMARY KEY (k1, k2));

INSERT  INTO sample VALUES (1, 2.0, 3, &#39;a&#39;), (2, 3.0, 4, &#39;b&#39;), (3, 4.0, 5, &#39;c&#39;);

SELECT  * FROM sample ORDER BY k1; UPDATE sample SET v1 = v1 &#43; 3, v2 = &#39;7&#39; WHERE k1 =  2 AND k2 = 3;

SELECT  * FROM sample ORDER BY k1;  </code>
  </pre>
  </div>

    </div>

    

    
                                            </div>
                                            <div><hr class="doc-hr">
<div id="doc-nav" class="d-print-none">

	<div class="row flex-xl-nowrap ">
	<div class="col-sm-6 pt-2 doc-next">
		<a href="../data-type/index.html">
			<div class="card h-100 my-1">
				<div class="card-body py-2">
                    <p class="card-title fs-5 fw-semibold lh-base mb-0"><i class="material-icons align-middle">navigate_before</i> 数据类型</p>
					
				</div>
			</div>
		</a>
        </div>
	<div class="col-sm-6 pt-2 doc-prev">
		<a class="ms-auto" href="../functions-and-operations/index.html">
			<div class="card h-100 my-1 text-end">
				<div class="card-body py-2">
                    <p class="card-title fs-5 fw-semibold lh-base mb-0">函数与操作 <i class="material-icons align-middle">navigate_next</i></p>
					
				</div>
			</div>
		</a>
        </div>
	</div>
</div></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
<footer class="shadow py-3 d-print-none">
    <div class="container-fluid">
        <div class="row align-items-center">
            <div class="col">
                <div class="text-sm-start text-center mx-md-2">
                    <p class="mb-0">
                        
                        
                    </p>
                </div>
            </div>
        </div>
    </div>
</footer>
</main>
            </div>
        </div>

        
        
        <button onclick="topFunction()" id="back-to-top" aria-label="Back to Top Button" class="back-to-top fs-5"><svg width="24" height="24"><path d="M12,10.224l-6.3,6.3L4.32,15.152,12,7.472l7.68,7.68L18.3,16.528Z" style="fill:#fff"/></svg></button>
        
        

        
        
            <script>(()=>{var e=document.getElementById("mode");e!==null&&(window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>{e.matches?(localStorage.setItem("theme","dark"),document.documentElement.setAttribute("data-dark-mode","")):(localStorage.setItem("theme","light"),document.documentElement.removeAttribute("data-dark-mode"))}),e.addEventListener("click",()=>{document.documentElement.toggleAttribute("data-dark-mode"),localStorage.setItem("theme",document.documentElement.hasAttribute("data-dark-mode")?"dark":"light")}),localStorage.getItem("theme")==="dark"?document.documentElement.setAttribute("data-dark-mode",""):document.documentElement.removeAttribute("data-dark-mode"))})()</script>
        




    
        
        
    
    






    

    <script src="../../../js/bootstrap.eac7ee3f6fa791c684e7a51fc2fd50b6f724271b9e39562e4fe8c3942412df3acbfc4045f043d03399dac70091207507.js"  defer></script>


    <script type="text/javascript" src="../../../js/bundle.min.ad2cedf5bf6173166579295b890c8a020e465c578d1a8833a9fad762c06e1e5133eb6f348c2644eb0bacfc38149db152.js"   crossorigin="anonymous" defer></script>
        

        
        
    </body>

<!-- Mirrored from docs.memfiredb.com/docs/db/guides/sql-grammar/ by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 27 Jun 2025 07:56:47 GMT -->
</html>